<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>无垠式通用代码生成器JEEEU版</title>
<link rel="stylesheet" type="text/css" href="../easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="../easyui/demo/demo.css">
<script type="text/javascript" src="../easyui/jquery.min.js"></script>
<script type="text/javascript" src="../easyui/jquery.easyui.min.js"></script>
<script src="../uploadjs/vendor/jquery.ui.widget.js"></script>
<script src="../uploadjs/jquery.iframe-transport.js"></script>
<script src="../uploadjs/jquery.fileupload.js"></script>
<style>
input,td.banner{
 width:180px;
}
input.plain{
 width:120px;
}
input.mycheck{
 width:40px;
}
.bar {
    height: 18px;
    background: green;
}

.lotus {
	background:url(../css/images/ada_float.png);
   	background-size:30%,30%;
    background-repeat:no-repeat;
    background-position:350px 50px;
    mix-blend-mode:darken;
}
</style>
</head>
<body class="easyui-layout">
<div data-options="region:'north',border:false" style="height:95px;overflow:hidden;background:#B3DFDA;padding:8px">
        <h1 style="font-size:16pt;"><a style="text-decoration: none;color:black;" href="https://gitee.com/jerryshensjf/InfinityJEEEU">无垠式通用代码生成器JEEEU版</a></h1><a style="text-decoration: none;color:black;position: absolute;top:30px;left:320px;font-size:10pt;" href="https://gitee.com/jerryshensjf/InfinityJEEEU">官网</a>
        <h2 style="font-size:9pt;"><a style="text-decoration: none;color:black;" href="https://gitee.com/jerryshensjf/InfinityJEEEU">自2014年起为公众服务</a></h2>
</div>
<div data-options="region:'west',split:true,title:'主菜单'" style="width:270px;padding:0px;">
<div class="easyui-accordion" data-options="fit:true,border:false">       						
<div title="功能菜单" style="padding:0px" data-options="selected:true">
<div id="mmadmin" data-options="inline:true" style="width: 250px; height: 98%; overflow: scroll; left: 0px; top: 0px; outline: none; display: block;" class="menu-top menu-inline menu easyui-fluid" tabindex="0"><div class="menu-line" style="height: 122px;"></div>
<div onclick="switchUrl('../html/index.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">脚本生成代码</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../html/parseexcel.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">上传生成代码</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../html/excelWizard.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">模板向导生成</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../html/compare.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">生成差异版本</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../html/transformer.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">SGS2模板转换</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../tools/multiTokenReplacer.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">贴心小工具</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../onlineqa/empty.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">空白Excel模板</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('CivMariaSample.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析CivMariaSample示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('GenerateSample.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析GenerateSample示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('LoginSample.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析LoginSample示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLGirlOnlyNode21.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLGirlOnlyNode21示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLGirlOnlyNode18.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLGirlOnlyNode18示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLEnumDemoOra.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLEnumDemoOra示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RedLotusDemoOra.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RedLotusDemoOra示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLOneOra.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLOneOra示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLGirlOnlyOra.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLGirlOnlyOra示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLDummyDemo.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLDummyDemo示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLEnumDemo.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLEnumDemo示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLGirlOnlyDummy.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLGirlOnlyDummy示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RedLotusDemo.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RedLotusDemo示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLCourseManagement.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLCourseManagement示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLCourseManagementPg.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLCourseManagementPg示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLGirlOnly.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLGirlOnly示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLGirlOnlyPg.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLGirlOnlyPg示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('TKDemo.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析TKDemo示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('RLOne.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析RLOne示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('One.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析One示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('OnePg.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析OnePg示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('CourseManagement.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析CourseManagement示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('GirlOnly.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析GirlOnly示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('GirlOnlyInit.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析GirlOnlyInit示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('CivMariaSample.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析CivMariaSample示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('CivPgSample.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析CivPgSample示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('CivOracleSample.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析CivOracleSample示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('UserSystemsFull.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析UserSystemsFull示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('UserSystems.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析UserSystems示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('UserSystemsPg.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析UserSystemsPg示例</div><div class="menu-icon icon-add"></div></div>

<div onclick="parseSampleTemplate('CivMariaSampleJ.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析CivMariaSampleJ示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('CourseManagementPgJ.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析CourseManagementPgJ示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('GirlOnlyOracleJ.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析GirlOnlyOracleJ示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('CivMariaSampleGo.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析CivMariaSampleGo示例</div><div class="menu-icon icon-add"></div></div>
<div onclick="parseSampleTemplate('GirlOnlyGo.xls')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">解析GirlOnlyGo示例</div><div class="menu-icon icon-add"></div></div>

<div onclick="window.location='../docs/Lotus_InstallUsage.docx'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">下载安装运行文档</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../docs/Lotus_UserManual.docx'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">下载用户手册</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../docs/动词算子式代码生成器开发者手册.pptx'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">下载开发者手册</div><div class="menu-icon icon-add"></div></div>

<div onclick="switchUrl('../onlineqa/node21_18_14_frontend.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">Nodejs前端代码生成物运行指南</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../onlineqa/newfunc.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">新版本新功能介绍</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../onlineqa/verbdenies.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">动词否定在线文档</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../onlineqa/onlineqa_index.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">在线问答</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../onlineqa/about.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">生成器简介</div><div class="menu-icon icon-add"></div></div>
<div onclick="switchUrl('../onlinedoc/luantan_index.html')" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">代码生成器技术乱弹</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../docs/Infinity面向棱柱动词算子式通用目的代码生成器详细设计.ppt'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">下载原理文档一</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../docs/动词算子式通用目的代码生成器基础理论讲纲.pptx'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">下载原理文档二</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../docs/代码生成原理浅析.ppt'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">下载原理文档三</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../docs/超级语言.pptx'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">下载原理文档四</div><div class="menu-icon icon-add"></div></div>
<div onclick="window.location='../docs/动词算子式代码生成器设计技术理论及实现.pptx'" class="menu-item" style="height: 20px;"><div class="menu-text" style="height: 20px; line-height: 20px;">下载原理文档五</div><div class="menu-icon icon-add"></div></div>
</div>
</div>
</div>
</div>
<div data-options="region:'east',split:true,collapsed:true,title:'属性'" style="width:250px;overflow: hidden">
</div>
<div data-options="region:'south',border:false" style="height:50px;background:#A9FACD;padding:10px;text-align: center">火箭船软件工作室版权所有。作者电邮:jerry_shen_sjf@qq.com QQ群:277689737</div>
<div data-options="region:'center',title:'代码生成器功能区'">
<div title="模板向导面板" class="easyui-panel lotus" style="width:1200px;height:10000px;">
<div style="float:left;font-size:12pt">生成结果:</div><br/><br/>
<div id="generateResults" style="width:800px"></div>
<div>模板向导</div>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#wupload').window('open')">上传并解析模板</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="downloadExcel()">生成并下载模板</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="wizardGenerateSource()">直接代码生成</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="autoReflectDb()">数据库自动反射</a><br>
<input type="checkbox" class="mycheck"  id="ignoreWarning" name="ignoreWarning"  value="true" />忽略编译警告<br>
<!-- <input type="checkbox" class="mycheck"  id="genFormatted" name="genFormatted" checked value="true" />生成格式化模板<br> -->
<input type="checkbox" class="mycheck"  id="generateFront" name="generateFront" value="true" checked/>生成前端<br>
<input type="checkbox" class="mycheck" id="autoConfig" name="autoConfig" checked value="true" onchange="toggleAutoConfig()"/>根据技术栈自动设置前端基地址<br>
<input type="checkbox" class="mycheck"  id="frontUseProjectName" name="frontUseProjectName" value="true" checked disabled/>前端API使用项目名<br>
<input type="checkbox" class="mycheck" id="frontUseControllerPrefix" name="frontUseControllerPrefix" value="true" checked disabled/>前端基地址使用控制器包名<br>
<input type="checkbox" class="mycheck" id="sqlComments" name="sqlComments" checked value="true" />数据库脚本增加注释<br>
<input type="checkbox" class="mycheck" id="javaCompatibility" name="javaCompatibility" checked value="true" />使用Java兼容性<br>
<input type="checkbox" class="mycheck" id="goCompatibility" name="goCompatibility" checked value="true" />使用Go兼容性<br>
<input type="checkbox" class="mycheck"   id="useAdvancedCustomize" name="useAdvancedCustomize" value="true" onchange="checkUseCust()"/>后端使用高级定制功能<br>
<div style="font-size:11pt;display:none;margin-left:20px" id="useCust">
&nbsp;&nbsp;<input type="checkbox" class="mycheck"  id="genUi" name="genUi" checked value="true" />生成界面
&nbsp;&nbsp;<input type="checkbox" class="mycheck"  id="genController" name="genController" checked value="true" />生成Controller
&nbsp;&nbsp;<input type="checkbox" class="mycheck"  id="genServiceImpl" name="genServiceImpl" checked value="true" />生成Service
&nbsp;&nbsp;<input type="checkbox" class="mycheck"  id="genDaoImpl" name="genDaoImpl" checked value="true" />生成Dao
</div>
<input type="checkbox" class="mycheck" id="useUserPartial" name="useUserPartial" value="true" onchange="checkUseUserPartial()"/>后端使用部分生成功能<br>
<form name="usePartialForm" id="usePartialForm" onblur="buildExportStr()">
<div style="font-size:11pt;display:none" id="usePartial">
</div>
</form>
<br/>
<div class="easyui-panel" title="项目设置" style="width:1180px">
<div style="padding:10px 20px 20px 20px">
<form id="projectform" method="post">
<table cellpadding="5">
<tr><td class="banner">fileName</td><td class="banner"><input  class='easyui-textbox' type='text' name='fileName' id='fileName' value='' data-options="required:true"/></td><td class="banner">project</td><td class="banner"><input  class='easyui-textbox' type='text' name='project' id='project' value='' data-options="required:true"/></td><td class="banner">packagetoken</td><td class="banner"><input  class='easyui-textbox' type='text' name='packagetoken' id='packagetoken' value='' data-options="required:false"/></td></tr>
<tr><td class="banner">dbprefix</td><td class="banner"><input class='easyui-textbox' type='text' name='dbprefix' id='dbprefix' value='' data-options="required:false"/></td><td class="banner">dbname</td><td class="banner"><input  class='easyui-textbox' type='text' name='dbname' id='dbname' value='' data-options="required:true"/></td><td class="banner">dbusername</td><td class="banner"><input  class='easyui-textbox' type='text' name='dbusername' id='dbusername' value='' data-options="required:true"/></td></tr>
<tr><td class="banner">dbpassword</td><td class="banner"><input class='easyui-textbox' type='text' name='dbpassword' id='dbpassword' value='' data-options="required:false"/></td>
<td class="banner">dbtype</td><td class="banner"><input class="easyui-combobox" id="dbtype" name="dbtype" value="mariadb" data-options="valueField: 'dbtype',textField: 'label', data: [
{dbtype: 'mariadb',label: 'MariaDB'},
{dbtype: 'mysql',label: 'MySQL'},
{dbtype: 'oracle',label: 'Oracle'},
{dbtype: 'postgresql',label: 'PostgreSQL'}]"/></td>
<td class="banner">technicalstack</td><td class="banner">
<input class="easyui-combobox" id="technicalstack" name="technicalstack" value='mjeeeu' onSelect="setupFrontBase()" data-options="valueField: 'value',textField: 'label', data: [
{value: 'jeeeu',label: 'jeeeu'},{value: 'mjeeeu',label: 'mjeeeu'}]"/></td></tr>
<tr><td class="banner">title</td><td class="banner"><input class='easyui-textbox' type='text' name='title' id='title' value='' data-options="required:false"/></td><td class="banner">subtitle</td><td class="banner"><input  class='easyui-textbox' type='text' name='subtitle' id='subtitle' value='' data-options="required:false"/></td><td class="banner">footer</td><td class="banner"><input  class='easyui-textbox' type='text' name='footer' id='footer' value='' data-options="required:false"/></td></tr>
<tr><td class="banner">crossorigin</td><td class="banner"><input class='easyui-textbox' type='text' name='crossorigin' id='crossorigin' value='' data-options="required:false"/></td>
<td class="banner">resolution</td><td class="banner">
<input class="easyui-combobox" id="resolution" name="resolution" value='high' data-options="valueField: 'value',textField: 'label', data: [
{value: 'high',label: 'high'},
{value: 'low',label: 'low'}]"/></td><td class="banner">domainsuffix</td><td class="banner"><input  class='easyui-textbox' type='text' name='domainsuffix' id='domainsuffix' value='domain' data-options="required:true"/></td></tr>
<tr><td class="banner">daosuffix</td><td class="banner"><input class='easyui-textbox' type='text' name='daosuffix' id='daosuffix' value='dao' data-options="required:true" disabled/></td><td class="banner">daoimplsuffix</td><td class="banner"><input  class='easyui-textbox' type='text' name='daoimplsuffix' id='daoimplsuffix' value='dao' data-options="required:true"/></td><td class="banner">servicesuffix</td><td class="banner"><input  class='easyui-textbox' type='text' name='servicesuffix' id='servicesuffix' value='service' data-options="required:true"  disabled/></td></tr>
<tr><td class="banner">serviceimplsuffix</td><td class="banner"><input class='easyui-textbox' type='text' name='serviceimplsuffix' id='serviceimplsuffix' value='service' data-options="required:true"/></td><td class="banner">controllersuffix</td><td class="banner"><input  class='easyui-textbox' type='text' name='controllersuffix' id='controllersuffix' value='controller' data-options="required:true"/></td><td class="banner">domainnamingsuffix</td><td class="banner"><input  class='easyui-textbox' type='text' name='domainnamingsuffix' id='domainnamingsuffix' value='' data-options="required:false"/></td></tr>
<tr><td class="banner">controllernamingsuffix</td><td class="banner"><input class='easyui-textbox' type='text' name='controllernamingsuffix' id='controllernamingsuffix' value='Controller' data-options="required:true"/></td>
<td class="banner">language</td><td class="banner">
<input class="easyui-combobox" id="language" name="language" value='chinese' data-options="valueField: 'value',textField: 'label', data: [
{value: 'chinese',label: 'Chinese'},
{value: 'english',label: 'English'}]"/></td>
<td class="banner">schema</td><td class="banner">
<input class="easyui-combobox" id="schema" name="schema" value='normal' data-options="valueField: 'value',textField: 'label', data: [
{value: 'normal',label: 'Normal'},
{value: 'dbtools',label: 'DBTools'},
{value: 'datadummy',label: 'DataDummy'}]"/></td></tr>
<tr><td class="banner">frontbaseapi</td><td class="banner"><input class='easyui-textbox' type='text' name='frontbaseapi' id='frontbaseapi' value='' data-options="required:false"/></td>
<td class="banner">frontendUi</td><td class="banner"><input class="easyui-combobox" id="frontendUi" name="frontendUi" value='vueElNode21' data-options="valueField: 'value',textField: 'label', data: [
{value: 'vueElNode21',label: 'Vue ElementUI on Nodejs 21'},
{value: 'vueElNode18',label: 'Vue ElementUI on Nodejs 18'},
{value: 'vueElNode14',label: 'Vue ElementUI on Nodejs 14'}]"/></td>
<td class="banner">backendUi</td><td class="banner"><input class="easyui-combobox" id="backendUi" name="backendUi" value='easyUi' data-options="valueField: 'value',textField: 'label', data: [
{value: 'easyUi',label: 'Easy UI'}]"/>
</td></tr>
<td class="banner">computerlanguage</td><td class="banner"><input class='easyui-textbox' type='text' name='computerlanguage' id='computerlanguage' value='rust' data-options="required:false"/></td>
<td class="banner"></td><td class="banner">
<td class="banner"></td><td class="banner">
</td></tr>
</table>
</form>
<div style="text-align:center;padding:5px">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="createNewBlankProject()">新建项目</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateProject(false)">更新项目设置</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="createNewDomain()">新增域对象</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="createNewEnum()">新增枚举</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="createNewMtmCandidate()">新增多对多候选</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="createNewModule()">新增登录模块</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="createParentChildLayout()">新增复杂版面</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="createEchartsReport()">新增报表</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">重置</a>
</div>
</div>
</div>
<br><br>
<div id="domainsdiv" style="overflow:display">
</div>

<div style="clear:both"></div>
<a href="../onlineqa/node21_18_14_frontend.html">请参考Nodejs21,18,14前端代码生成物运行指南</a><br><br>
<a href="../onlineqa/empty.html">请参考空白Excel模板</a><br><br>
<a href="../onlineqa/verbdenies.html">请参考动词否定在线文档</a><br><br>
<a href="../onlineqa/about.html">无垠式通用代码生成器JEEEU版的简介</a>
<br>
</div>
</div>

<div id="wsetSepecial" class="easyui-window" title="设置字段" data-options="iconCls:'icon-save',modal:true,closable:true,draggable:true,resizable:false,shadow:true,minimizable:true,maximizable:false,collapsible:false,closed:true" style="width:1000px;height:600px;text-align:center">
<form id="domainfieldsform" name="domainfieldsform" method="post">
<input type="hidden" id="serial" name="serial" value="0"/>
<table style="padding-top: 20px">
<tr>
<th>字段类型</th><th>字段名</th><th>类型</th><th>长度</th><th>标签</th><th>固定名字</th><th>操作</th>
</tr>
<tbody id="fieldsBody">
<tr><td>domainid</td><td><input type="text" class="easyui-textbox plain"  id="domainid" name="domainid"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainidtype" name="domainidtype" value="Long"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainidlength" name="domainidlength" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainidlabel" name="domainidlabel" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainidfixedname" name="domainidfixedname" value=""></input></td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="domainiddeny" name="domainiddeny">不使用</input></td></tr>
<tr><td>domainname</td><td><input type="text" class="easyui-textbox plain" id="domainname" name="domainname"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainnametype" name="domainnametype" value="String"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainnamelength" name="domainnamelength" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainnamelabel" name="domainidlabel" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainnamefixedname" name="domainnamefixedname" value=""></input></td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="domainnamedeny" name="domainnamedeny">不使用</input></td></tr>
<tr><td>activefield</td><td><input type="text" class="easyui-textbox plain"  id="activefield" name="activefield"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="activefieldtype" name="activefieldtype" value="Boolean"></td>
<td><input type="text" class="easyui-textbox plain"  id="activefieldlength" name="activefieldlength" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="activefieldlabel" name="activefieldlabel" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="activefieldfixedname" name="activefieldfixedname" value=""></input></td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="activefielddeny" name="activefielddeny">不使用</input></td></tr>
</tbody>
<tfoot>
<tr><td colspan="7" style="text-align: center">
<input class="easyui-button plain" type="button" id="submitBtn" name="submitBtn" value="保存设置" onclick="setupDomainFields($('#domainfieldsform').find('#serial').val())" />
<input class="easyui-button plain" type="button" id="addFieldBtn" name="addFieldBtn" value="新增字段" onclick="addFieldRow()" />
<input class="easyui-button plain" type="reset" id="resetBtn" name="resetBtn" value="取消" />
</td>
</tr>
</tfoot>
</table>
</form>
</div>

<div id="waddDataDomain" class="easyui-window" title="设置域对象数据" data-options="iconCls:'icon-save',modal:true,closable:true,draggable:true,resizable:false,shadow:true,minimizable:true,maximizable:false,collapsible:false,closed:true" style="width:880px;height:600px;text-align:center">
<form id="datadomainfieldsform" name="datadomainfieldsform" method="post">
<input type="hidden" name="serial" id="serial" value="0"/>
<table style="padding-top: 20px">
<tr>
<th>字段类型</th><th>字段名</th><th>标签</th><th>固定名字</th><th>值</th><th>操作</th>
</tr>
<tbody id="fieldsBody">
<tr><td>domainid</td><td><input type="text" class="easyui-textbox plain"  id="domainid" name="domainid"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainidlabel" name="domainidlabel" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainidfixedname" name="domainidfixedname" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainidvalue" name="domainidvalue" value=""></input></td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="domainiddeny" name="domainiddeny">不使用</input></td></tr>
<tr><td>domainname</td><td><input type="text" class="easyui-textbox plain" id="domainname" name="domainname"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainnamelabel" name="domainnamelabel" value="String"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainnamefixedname" name="domainnamefixedname" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainnamevalue" name="domainnamevalue" value=""></input></td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="domainnamedeny" name="domainnamedeny">不使用</input></td></tr>
<tr><td>activefield</td><td><input type="text" class="easyui-textbox plain"  id="activefield" name="activefield"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="activefieldlabel" name="activefieldlabel" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="activefieldfixedname" name="activefieldfixedname" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="activefieldvalue" name="activefieldvalue" value=""></input></td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="activefielddeny" name="activefielddeny">不使用</input></td></tr>
</tbody>
<tfoot>
<tr><td colspan="7" style="text-align: center">
<input class="easyui-button plain" type="button" id="submitBtn" name="submitBtn" value="提交数据" onclick="addDataDomain()" />
<input class="easyui-button plain" type="reset" id="resetBtn" name="resetBtn" value="取消" />
</td>
</tr>
</tfoot>
</table>
</form>
</div>


<div id="wupdateDataDomain" class="easyui-window" title="编辑域对象数据" data-options="iconCls:'icon-save',modal:true,closable:true,draggable:true,resizable:false,shadow:true,minimizable:true,maximizable:false,collapsible:false,closed:true" style="width:880px;height:600px;text-align:center;display: none;">
<form id="updatedatadomainform" name="updatedatadomainform" method="post">
<input type="hidden" name="serial" id="serial" value="-1"/>
<input type="hidden" name="index" id="index" value="-1"/>
<table style="padding-top: 20px">
<tr>
<th>字段类型</th><th>字段名</th><th>标签</th><th>固定名字</th><th>值</th><th>操作</th>
</tr>
<tbody id="fieldsBody">
<tr><td>domainid</td><td><input type="text" class="easyui-textbox plain"  id="domainid" name="domainid"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainidlabel" name="domainidlabel" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainidfixedname" name="domainidfixedname" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainidvalue" name="domainidvalue" value=""></input></td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="domainiddeny" name="domainiddeny" checked>不使用</input></td></tr>
<tr><td>domainname</td><td><input type="text" class="easyui-textbox plain" id="domainname" name="domainname"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainnamelabel" name="domainnamelabel" value="String"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainnamefixedname" name="domainnamefixedname" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="domainnamevalue" name="domainnamevalue" value=""></input></td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="domainnamedeny" name="domainnamedeny" checked>不使用</input></td></tr>
<tr><td>activefield</td><td><input type="text" class="easyui-textbox plain"  id="activefield" name="activefield"></input></td>
<td><input type="text" class="easyui-textbox plain"  id="activefieldlabel" name="activefieldlabel" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="activefieldfixedname" name="activefieldfixedname" value=""></input></td>
<td><input type="text" class="easyui-textbox plain"  id="activefieldvalue" name="activefieldvalue" value=""></input></td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="activefielddeny" name="activefielddeny" checked>不使用</input></td></tr>
</tbody>
<tfoot>
<tr><td colspan="7" style="text-align: center">
<input class="easyui-button plain" type="button" id="submitBtn" name="submitBtn" value="提交数据" onclick="updateDataDomain()" />
<input class="easyui-button plain" type="button" id="resetBtn" name="resetBtn" value="取消" onclick="$('#wupdateDataDomain').window('close'); "/>
</td>
</tr>
</tfoot>
</table>
</form>
</div>

<div id="wupload" class="easyui-window" title="上传模板" data-options="iconCls:'icon-save',modal:true,closable:true,draggable:true,resizable:false,shadow:true,minimizable:true,maximizable:false,collapsible:false,closed:true" style="width:400px;height:300px;text-align:center;display: none;">
<br>
<h2>上传模板并解析</h2>
<br><br>
<form id="uploadform" name="uploadform" method="post">
<input id="fileupload" type="file" name="files[]" data-url="../facade/uploadAndParseTemplateFacade" multiple style="width:360px"><br>
<input type="checkbox" class="mycheck"  id="uploadIgnoreWarning" name="uploadIgnoreWarning"  value="true" />忽略编译警告<br>
<input type="checkbox" class="mycheck" id="javaCompatibility" name="javaCompatibility" checked value="true" />使用Java兼容性<br>
<input type="checkbox" class="mycheck" id="goCompatibility" name="goCompatibility" checked value="true" />使用Go兼容性<br>
</form>
</div>

<div id="menu" class="easyui-menu" style="width: 30px; display: none;">
<!--放置一个隐藏的菜单Div-->
<!--具体的菜单事件请自行添加，跟toolbar的方法是基本一样的-->
<div id="btn_Modify" data-options="iconCls:'icon-edit'" onclick="initUpdateDataDomain()">编辑</div>
<div id="btn_Delete" data-options="iconCls:'icon-remove'" onclick="deleteDataDomain()">删除</div>
<div id="btn_DeletAll" data-options="iconCls:'icon-remove'" onclick="wdeleteAllDataDomains($('#menuform').find('#serial').val())">清空数据</div>
<form id="menuform" name="menuform" method="POST">
<input type="hidden" id="serial" name="serial" value="-1"/>
<input type="hidden" id="index" name="index" value="-1"/>
</form>
</div>

<div id="wdenywizzard" class="easyui-window" title="动词否定向导" style="width: 520px;text-align:center" data-options="closed:true">
<form name="denywizzardform" id="denywizzardform" >
<input type="hidden" id="index" name="index" value="0"/>
<br>
<div id="validateResults"></div>
<br>
<table style="text-align:left;width:480px;margin-left:20px">
<tr>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="max" name="max" value="max">max</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="maxplus" name="maxplus" value="max+">max+</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="activate" name="activate" value="Activate">Activate</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="activateall" name="activateall" value="ActivateAll">ActivateAll</td>
</tr>
<tr>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="add" name="add" value="Add">Add</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="clone" name="clone" value="Clone">Clone</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="cloneall" name="cloneall" value="CloneAll">CloneAll</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="delete" name="delete" value="Delete">Delete</td>
</tr>
<tr>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="deleteall" name="deleteall" value="DeleteAll">DeleteAll</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="export" name="export" value="Export">Export</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="filterexcel" name="filterexcel" value="FilterExcel">FilterExcel</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="findbyname" name="findbyname" value="FindByName">FindByName</td>
</tr>
<tr>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="softdelete" name="softdelete" value="SoftDelete">SoftDelete</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="softdeleteall" name="softdeleteall" value="SoftDeleteAll">SoftDeleteAll</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="toggle" name="toggle" value="Toggle">Toggle</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="toggleone" name="toggleone" value="ToggleOne">ToggleOne</td>
</tr>
<tr>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="update" name="update" value="Update">Update</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="view" name="view" value="View">View</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="exportpdf" name="exportpdf" value="ExportPDF">ExportPDF</td>
<td><input type="checkbox" class="easyui-checkbox mycheck" id="filterpdf" name="filterpdf" value="FilterPDF">FilterPDF</td>
</table>
<br><br>
<input class="easyui-button plain" type="button" id="submitBtn" name="submitBtn" value="确定" onclick="buildDenyStr()"/>
<input class="easyui-button plain" type="button" id="resetBtn" name="resetBtn" value="取消" onclick="$('#wdenywizzard').window('close'); "/>
</form>
</div>

<div class="easyui-window" title="编辑数据库" id="wupdateDb" data-options="iconCls:'icon-save',modal:true,closed:true" style="width:500px;height:500px">
<div style="padding:10px 60px 20px 60px">
<form id="ffdbedit" method="post">
<input type='hidden' name='id' id='id' value=''/>
<table cellpadding="5">
<tr><td>数据库类型:</td><td><input class="easyui-combobox" id="dbType" name="dbType" data-options="valueField: 'value',textField: 'label', data: [
{value: 'MariaDB',label: 'MariaDB'},
{value: 'MySQL',label: 'MySQL'},
{value: 'PostgreSQL',label: 'PostgreSQL'}]"/></td></tr>
<tr><td>数据库服务器:</td><td><input class='easyui-textbox' type='text' name='dbHost' id='dbHost' value='' data-options="required:true"/></td></tr>
<tr><td>数据库端口:</td><td><input class='easyui-textbox' type='text' name='dbPort' id='dbPort' value='' data-options="required:true"/></td></tr>
<tr><td>数据库名:</td><td><input class='easyui-combobox' type='text' name='databaseName' id='databaseName' data-options="required:false,valueField:'databaseName', textField:'databaseName', url: '../facade/listAllDatabasesFacade'"/></td></tr>
<tr><td>取记录数:</td><td><input  class='easyui-combobox' type='text' name='topn' id='topn' data-options="required:false,valueField:'value', textField: 'label', data: [
{value: '-1',label: '全部记录'},
{value: '0',label: '空白记录'},
{value: '1000',label: '1000'},
{value: '2000',label: '2000'},
{value: '5000',label: '5000'}]"/></td></tr>
<tr><td>用户名:</td><td><input class='easyui-textbox' type='text' name='userName' id='userName' value='' data-options="required:true"/></td></tr>
<tr><td>密码:</td><td><input class='easyui-textbox' type='text' name='password' id='password' value='' data-options="required:true"/></td></tr>
</table>
</form>
<div style="text-align:center;padding:5px">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateDbSettings()">编辑数据库设置</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="reflectDbToProject()">数据库反射项目</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#ffdbedit').form('clear');">清除</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#wupdateDb').window('close')">取消</a>
</div>
</div>

<div class="easyui-window" title="编辑多对多候选数据" id="wupdateMtmCandidateData" data-options="iconCls:'icon-save',modal:true,closed:true" style="width:500px;height:300px">
<div style="padding:10px 60px 20px 60px">
<form id="ffupdateMtmCandidateData" method="post">
<input type='hidden' name='serial' id='serial' value=''/>
<input type='hidden' name='index' id='index' value=''/>
<table cellpadding="5">
<tr><td>主对象序号:</td><td><input class='easyui-textbox' type='text' name='masterId' id='masterId' value='' data-options="required:true"/></td></tr>
<tr><td>从对象序号:</td><td><input class='easyui-textbox' type='text' name='slaveIds' id='slaveIds' value='' data-options="required:true"/></td></tr>
</table>
</form>
<div style="text-align:center;padding:5px">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitMtmCandidateData()">提交</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#ffupdateMtmCandidateData').form('clear');">清除</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#wupdateMtmCandidateData').window('close')">取消</a>
</div>
</div>
</body>
<script type="text/javascript">
var params = {};
var pagesize = 10;
var pagenum = 1;
var toolbar = [];

$(function () {	
	$('#projectform').find("#schema").combobox({
		onChange: function(newValue,oldValue) {
			if (newValue == 'datadummy') $('#projectform').find("#dbtype").combobox("setValue","mariadb");
		}
	});
    $('#fileupload').fileupload({
        dataType: 'json',  
        async: false,
        formData : function() {
            return [{name:"ignoreWarning",value:$("#uploadIgnoreWarning").prop("checked")},
            		{name:"javaCompatibility",value:$("#uploadform").find("#javaCompatibility").prop("checked")},
            		{name:"goCompatibility",value:$("#uploadform").find("#goCompatibility").prop("checked")}
            	];
        },
        success: function(data, textStatus) {
           if (data.success == true){
        	   	$("#generateResults").html("");
				$("#wupload").window('close');
				$.messager.alert("信息", "模板上传解析成功，欢迎使用！");
				listServerData();
           }else if (data.success == false){
        	   $("#wupload").window('close');
        	   var resultStr ="";
        	   if (data.compileErrors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.compileErrors.length;i++){
	        		   resultStr += data.compileErrors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (data.compileWarnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.compileWarnings.length;i++){
	        		   resultStr += data.compileWarnings[i];
	        		   resultStr += "<br/>"
    	 		    }
        	   		resultStr += "</span>";
        	   }
        	   if (!!resultStr) $("#generateResults").html(resultStr);
           }
        }
	});
    
    $("#ffdbedit").find("#dbType").combobox({
        onChange: function (newValue, oldValue) {
        	var dbType = newValue;
        	if (dbType == "MariaDB") {
        		$('#ffdbedit').find("#dbPort").textbox("setValue","3306");
        		$('#ffdbedit').find("#userName").textbox("setValue","jerry");
        		$('#ffdbedit').find("#password").textbox("setValue","jerry");
        	} else if (dbType == "MySQL") {
        		$('#ffdbedit').find("#dbPort").textbox("setValue","3306");
        		$('#ffdbedit').find("#userName").textbox("setValue","root");
        		$('#ffdbedit').find("#password").textbox("setValue","jerry");
        	} else if (dbType == "PostgreSQL"){
        		$('#ffdbedit').find("#dbPort").textbox("setValue","5432");
        		$('#ffdbedit').find("#userName").textbox("setValue","postgres");
        		$('#ffdbedit').find("#password").textbox("setValue","postgres");
        	}
        }
    });

    $("#denywizzardform").find("#max").checkbox({
        onChange: function (newValue, oldValue) {
        	if ($("#denywizzardform").find("#max").checkbox("options").checked == true) {
        		clearCheckBoxesInDenyWizzardFormWithoutMax();
        	}
        }
    });

    $("#denywizzardform").find("#maxplus").checkbox({
        onChange: function (newValue, oldValue) {
        	if ($("#denywizzardform").find("#maxplus").checkbox("options").checked == true) {
        		$("#denywizzardform").find("#max").checkbox({checked: false}); 
        	}
        }
    });
	$('#projectform').find("#technicalstack").combobox({
		onSelect: function(record){
			setupFrontBase(record.value);
		}
	});
	
    $("#updatedatadomainform").find("#domainiddeny").checkbox({
    	checked: true,
    	readonly: true
	});
    
    $("#updatedatadomainform").find("#domainnamedeny").checkbox({
    	checked: true,
    	readonly: true
    });
    
    $("#updatedatadomainform").find("#activefielddeny").checkbox({
    	checked: true,
    	readonly: true
    });
});

$(document).ready(function(){
    $.extend($.fn.validatebox.defaults.rules, {
        nameLength: {
            validator: function(value, param){
                //正则表达式需要动态传递参数，必须采用正则对象即构造器方式，传入拼接了动态参数的字符串的方式
                var re =new RegExp("^[\u4e00-\u9fa5]|[a-zA-Z0-9]{" + param[0]+ "," + param[1] + "}$");
                return re.test(value);
            },
            //提示信息中也需要动态添加参数，此时获取param中的参数方式为{0}、{1}，分别代表param[0]，param[1]
            message: "名称长度要求为{0}-{1}位!"
        },
        equals: {
    		validator: function(value,param){
    			return value == $(param[0]).val();
    		},
    		message: '字段不符合校验要求！'
        },
        notBlank: {
    		validator: function(value,param){
    			return !isBlank($(param[0]).val());
    		},
    		message: '字段不可为空！'
        }
    });
	$('#wsetSepecial').window('close'); 
	$('#waddDataDomain').window('close'); 
	$('#wupdateDataDomain').window('close'); 
	$('#wupload').window('close'); 
	clearForm();
	listServerData();
});

function setupFrontBase(value){
	$("#frontUseProjectName").get(0).checked=true;
	$("#frontUseControllerPrefix").get(0).checked=true;
}

function subStringInside(denystr, subStr){
	if (isBlank(denystr)) return false;
	var arr = denystr.split(",");
	for (var i=0;i<arr.length;i++){
		if (arr[i]==subStr) return true;
	}
	return false;
}

function countSubstr(str, substr, isIgnore) {
	var count;
	var reg = "";
	if (isIgnore == true) {
		reg = "/" + substr + "/gi";
	} else {
		reg = "/" + substr + "/g";
	}
	reg = eval(reg);
	if (str.match(reg) == null) {
		count = 0;
	} else {
		count = str.match(reg).length;
	}
	return count;
}
function buildDenyStr(){
	var pos = $("#denywizzardform").find("#index").val();
	var denystr = "";
	if ($("#denywizzardform").find("#max").checkbox("options").checked == true) {
		denystr="max";
		$($("#domainsdiv").find(".domainForm").get(pos)).find("#verbdenies").textbox("setValue",denystr);
		$("#wdenywizzard").window("close");
		return;
	}
	if ($("#denywizzardform").find("#maxplus").checkbox("options").checked==true) denystr="max+,";
	if ($("#denywizzardform").find("#activate").checkbox("options").checked==true) denystr+= "Activate,";
	if ($("#denywizzardform").find("#activateall").checkbox("options").checked==true) denystr+= "ActivateAll,";
	if ($("#denywizzardform").find("#add").checkbox("options").checked==true) denystr+= "Add,";
	if ($("#denywizzardform").find("#clone").checkbox("options").checked==true) denystr+= "Clone,";
	if ($("#denywizzardform").find("#cloneall").checkbox("options").checked==true) denystr+= "CloneAll,";
	if ($("#denywizzardform").find("#delete").checkbox("options").checked==true) denystr+= "Delete,";
	if ($("#denywizzardform").find("#deleteall").checkbox("options").checked==true) denystr+= "DeleteAll,";
	if ($("#denywizzardform").find("#export").checkbox("options").checked==true) denystr+= "Export,";
	if ($("#denywizzardform").find("#exportpdf").checkbox("options").checked==true) denystr+= "ExportPDF,";
	//if ($("#denywizzardform").find("#exportword").checkbox("options").checked==true) denystr+= "ExportWord,";
	if ($("#denywizzardform").find("#filterexcel").checkbox("options").checked==true) denystr+= "FilterExcel,";
	if ($("#denywizzardform").find("#filterpdf").checkbox("options").checked==true) denystr+= "FilterPDF,";
	//if ($("#denywizzardform").find("#filterword").checkbox("options").checked==true) denystr+= "FilterWord,";
	if ($("#denywizzardform").find("#findbyname").checkbox("options").checked==true) denystr+= "FindByName,";
	if ($("#denywizzardform").find("#softdelete").checkbox("options").checked==true) denystr+= "SoftDelete,";
	if ($("#denywizzardform").find("#softdeleteall").checkbox("options").checked==true) denystr+= "SoftDeleteAll,";
	if ($("#denywizzardform").find("#toggle").checkbox("options").checked==true) denystr+= "Toggle,";
	if ($("#denywizzardform").find("#toggleone").checkbox("options").checked==true) denystr+= "ToggleOne,";
	if ($("#denywizzardform").find("#update").checkbox("options").checked==true) denystr+= "Update,";
	if ($("#denywizzardform").find("#view").checkbox("options").checked==true) denystr+= "View,";
	if (denystr.indexOf(",") != -1) denystr = denystr.substring(0,denystr.length-1);
	
	$.ajax({
        type: "post",
        url: "../facade/validateVerbDenyStrFacade",
        data: {domainName:$($("#domainsdiv").find(".domainForm").get(pos)).find("#domain").textbox("getValue"),
        	verbDenyStr:denystr
       	},
        dataType: 'json', 
        success: function(data, textStatus) {
	           if (data.success == true){	        	   
	        		$($("#domainsdiv").find(".domainForm").get(pos)).find("#verbdenies").textbox("setValue",denystr);
	        		$("#wdenywizzard").window("close");
	           }else if (data.success == false){
	        	   var resultStr ="";
	        	   if (data.compileErrors.length > 0) {
		        	   resultStr = "<span style='color:red;font-size:16pt''>";
		        	   for (var i = 0; i < data.compileErrors.length;i++){
		        		   resultStr += data.compileErrors[i];
		        		   resultStr += "<br/>"
	        	 		   }   
		        	   resultStr += "</span>";
		           }
	        	   if (data.compileWarnings.length > 0){
		        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
		        	   for (var i = 0; i < data.compileWarnings.length;i++){
		        		   resultStr += data.compileWarnings[i];
		        		   resultStr += "<br/>" 
		        	   }
		        	   resultStr += "</span>";
	        	   }
        		   if (!!resultStr) $("#wdenywizzard").find("#validateResults").html(resultStr);
	           }
	        }
	});
}

function clearCheckBoxesInDenyWizzardForm(){
	$("#denywizzardform").find("#max").checkbox({checked: false}); 
	$("#denywizzardform").find("#maxplus").checkbox({checked: false}); 
	$("#denywizzardform").find("#activate").checkbox({checked: false}); 
	$("#denywizzardform").find("#activateall").checkbox({checked: false}); 
	$("#denywizzardform").find("#add").checkbox({checked: false}); 
	$("#denywizzardform").find("#clone").checkbox({checked: false}); 
	$("#denywizzardform").find("#cloneall").checkbox({checked: false}); 
	$("#denywizzardform").find("#delete").checkbox({checked: false}); 
	$("#denywizzardform").find("#deleteall").checkbox({checked: false}); 
	$("#denywizzardform").find("#export").checkbox({checked: false}); 
	$("#denywizzardform").find("#exportpdf").checkbox({checked: false}); 
	//$("#denywizzardform").find("#exportword").checkbox({checked: false}); 
	$("#denywizzardform").find("#filterexcel").checkbox({checked: false}); 
	$("#denywizzardform").find("#filterpdf").checkbox({checked: false}); 
	//$("#denywizzardform").find("#filterword").checkbox({checked: false}); 
	$("#denywizzardform").find("#findbyname").checkbox({checked: false}); 
	$("#denywizzardform").find("#softdelete").checkbox({checked: false}); 
	$("#denywizzardform").find("#softdeleteall").checkbox({checked: false}); 
	$("#denywizzardform").find("#toggle").checkbox({checked: false}); 
	$("#denywizzardform").find("#toggleone").checkbox({checked: false}); 
	$("#denywizzardform").find("#update").checkbox({checked: false}); 
	$("#denywizzardform").find("#view").checkbox({checked: false}); 
}

function clearCheckBoxesInDenyWizzardFormWithoutMax(){
	$("#denywizzardform").find("#maxplus").checkbox({checked: false}); 
	$("#denywizzardform").find("#activate").checkbox({checked: false}); 
	$("#denywizzardform").find("#activateall").checkbox({checked: false}); 
	$("#denywizzardform").find("#add").checkbox({checked: false}); 
	$("#denywizzardform").find("#clone").checkbox({checked: false}); 
	$("#denywizzardform").find("#cloneall").checkbox({checked: false}); 
	$("#denywizzardform").find("#delete").checkbox({checked: false}); 
	$("#denywizzardform").find("#deleteall").checkbox({checked: false}); 
	$("#denywizzardform").find("#export").checkbox({checked: false}); 
	$("#denywizzardform").find("#exportpdf").checkbox({checked: false}); 
	//$("#denywizzardform").find("#exportword").checkbox({checked: false}); 
	$("#denywizzardform").find("#filterexcel").checkbox({checked: false}); 
	$("#denywizzardform").find("#filterpdf").checkbox({checked: false}); 
	//$("#denywizzardform").find("#filterword").checkbox({checked: false}); 
	$("#denywizzardform").find("#findbyname").checkbox({checked: false}); 
	$("#denywizzardform").find("#softdelete").checkbox({checked: false}); 
	$("#denywizzardform").find("#softdeleteall").checkbox({checked: false}); 
	$("#denywizzardform").find("#toggle").checkbox({checked: false}); 
	$("#denywizzardform").find("#toggleone").checkbox({checked: false}); 
	$("#denywizzardform").find("#update").checkbox({checked: false}); 
	$("#denywizzardform").find("#view").checkbox({checked: false}); 
}

function initDenyWizzard(pos){
	$("#wdenywizzard").find("#validateResults").html("");
	clearCheckBoxesInDenyWizzardForm();
	$("#denywizzardform").find("#index").val(pos);
	var denystr = $($("#domainsdiv").find(".domainForm").get(pos)).find("#verbdenies").val();
	parseDenyStr(pos,denystr);
	$("#wdenywizzard").window("open");
}

function parseDenyStr(pos,denystr){
	if (isBlank(denystr)) {
		return;
	} 
	if (subStringInside(denystr,"max")){
		$("#denywizzardform").find("#max").checkbox({checked: true}); 
		return;
	}
	if (subStringInside(denystr,"max+")) $("#denywizzardform").find("#maxplus").checkbox({checked: true}); 
	if (subStringInside(denystr,"Activate")) $("#denywizzardform").find("#activate").checkbox({checked: true}); 
	if (subStringInside(denystr,"ActivateAll"))$("#denywizzardform").find("#activateall").checkbox({checked: true}); 	
	if (subStringInside(denystr,"Add")) $("#denywizzardform").find("#add").checkbox({checked: true}); 
	if (subStringInside(denystr,"Clone")) $("#denywizzardform").find("#clone").checkbox({checked: true}); 
	if (subStringInside(denystr,"CloneAll")) $("#denywizzardform").find("#cloneall").checkbox({checked: true}); 
	if (subStringInside(denystr,"Delete")) $("#denywizzardform").find("#delete").checkbox({checked: true}); 
	if (subStringInside(denystr,"DeleteAll")) $("#denywizzardform").find("#deleteall").checkbox({checked: true}); 
	if (subStringInside(denystr,"Export")) $("#denywizzardform").find("#export").checkbox({checked: true}); 
	if (subStringInside(denystr,"ExportPDF")) $("#denywizzardform").find("#exportpdf").checkbox({checked: true}); 
	//if (subStringInside(denystr,"ExportWord")) $("#denywizzardform").find("#exportword").checkbox({checked: true}); 
	if (subStringInside(denystr,"FilterExcel")) $("#denywizzardform").find("#filterexcel").checkbox({checked: true}); 
	if (subStringInside(denystr,"FilterPDF")) $("#denywizzardform").find("#filterpdf").checkbox({checked: true}); 
	//if (subStringInside(denystr,"FilterWord")) $("#denywizzardform").find("#filterword").checkbox({checked: true}); 
	if (subStringInside(denystr,"FindByName")) $("#denywizzardform").find("#findbyname").checkbox({checked: true}); 
	if (subStringInside(denystr,"SoftDelete")) $("#denywizzardform").find("#softdelete").checkbox({checked: true}); 
	if (subStringInside(denystr,"SoftDeleteAll")) $("#denywizzardform").find("#softdeleteall").checkbox({checked: true}); 
	if (subStringInside(denystr,"Toggle")) $("#denywizzardform").find("#toggle").checkbox({checked: true}); 
	if (subStringInside(denystr,"ToggleOne")) $("#denywizzardform").find("#toggleone").checkbox({checked: true}); 
	if (subStringInside(denystr,"Update")) $("#denywizzardform").find("#update").checkbox({checked: true}); 
	if (subStringInside(denystr,"View")) $("#denywizzardform").find("#view").checkbox({checked: true}); 
}

function createNewProject(){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"createNewProject",
        	fileName:$("#fileName").val(),
        	project:$("#project").val(),
        	packagetoken:$("#packagetoken").val(),
        	dbprefix:$("#dbprefix").val(),
        	dbname:$("#dbname").val(),
        	dbusername:$("#dbusername").val(),
        	dbpassword:$("#dbpassword").val(),
        	dbtype:$("#dbtype").val(),
        	technicalstack:$("#technicalstack").val(),
        	title:$("#title").val(),
        	subtitle:$("#subtitle").val(),
        	footer:$("#footer").val(),
        	crossorigin:$("#crossorigin").val(),
        	resolution:$("#resolution").val(),
        	domainsuffix:$("#domainsuffix").val(),
        	daosuffix:$("#daosuffix").val(),
        	daoimplsuffix:$("#daoimplsuffix").val(),
        	servicesuffix:$("#servicesuffix").val(),
        	serviceimplsuffix:$("#serviceimplsuffix").val(),
        	controllersuffix:$("#controllersuffix").val(),
        	domainnamingsuffix:$("#domainnamingsuffix").val(),
        	controllernamingsuffix:$("#controllernamingsuffix").val(),
        	language:$("#language").val(),
        	schema:$("#schema").val(),
        	frontbaseapi:$("#frontbaseapi").val(),
        	frontendUi:$("#frontendUi").val(),
        	backendUi:$("#backendUi").val(),
        	computerlanguage:$("#computerlanguage").val()
       	},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   $.messager.alert("信息", "新建项目成功，欢迎使用！");
        	   listServerData();
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}


function clearForm(){
	$("#generateResults").html("");
	$("#projectform").get(0).reset();
	$("#projectform").find("#dbtype").combobox("select","mariadb");
	$("#projectform").find("#domainsuffix").textbox("setValue","domain");
	$("#projectform").find("#daosuffix").textbox("setValue","dao");
	$("#projectform").find("#daoimplsuffix").textbox("setValue","dao");
	$("#projectform").find("#servicesuffix").textbox("setValue","service");
	$("#projectform").find("#serviceimplsuffix").textbox("setValue","service");
	$("#projectform").find("#controllersuffix").textbox("setValue","controller");
	$("#projectform").find("#controllernamingsuffix").textbox("setValue","Controller");
	$("#projectform").find("#language").combobox("select","chinese");
	$("#projectform").find("#schema").combobox("select","normal");	
	$("#projectform").find("#technicalstack").combobox("select","mjeeeu");	
	$("#projectform").find("#resolution").combobox("select","high");
	$("#projectform").find("#frontbaseapi").textbox("setValue","");
	$("#projectform").find("#frontendUi").combobox("setValue","vueElNode21");
	$("#projectform").find("#backendUi").combobox("setValue","easyUi");
	$("#projectform").find("#computerlanguage").textbox("setValue","rust");
}


function createNewBlankProject(){
	clearForm();
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"createNewProject",
        	fileName:$("#fileName").val(),
        	project:$("#project").val(),
        	packagetoken:$("#packagetoken").val(),
        	dbprefix:$("#dbprefix").val(),
        	dbname:$("#dbname").val(),
        	dbusername:$("#dbusername").val(),
        	dbpassword:$("#dbpassword").val(),
        	dbtype:$("#dbtype").val(),
        	technicalstack:$("#technicalstack").val(),
        	title:$("#title").val(),
        	subtitle:$("#subtitle").val(),
        	footer:$("#footer").val(),
        	crossorigin:$("#crossorigin").val(),
        	resolution:$("#resolution").val(),
        	domainsuffix:$("#domainsuffix").val(),
        	daosuffix:$("#daosuffix").val(),
        	daoimplsuffix:$("#daoimplsuffix").val(),
        	servicesuffix:$("#servicesuffix").val(),
        	serviceimplsuffix:$("#serviceimplsuffix").val(),
        	controllersuffix:$("#controllersuffix").val(),
        	domainnamingsuffix:$("#domainnamingsuffix").val(),
        	controllernamingsuffix:$("#controllernamingsuffix").val(),
        	language:$("#language").val(),
        	schema:$("#schema").val(),
        	frontbaseapi:$("#frontbaseapi").val(),
        	frontendUi:$("#frontendUi").val(),
        	backendUi:$("#backendUi").val(),
        	computerlanguage:$("#computerlanguage").val()
       	},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   $.messager.alert("信息", "新建项目成功，欢迎使用！");
        	   listServerData();
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function validateServerProject(){
	var retVal = true;
	$.ajax({
        type: "post",
        async:false,
        url: "../facade/excelWizardFacade",
        data: {command:"validateServerProject"       	
    	},
        dataType: 'json',
        success: function(data, textStatus) {
			debugger;
			if (data.success == false){
        	   var resultStr ="";
        	   if (!!data.compileErrors && data.compileErrors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.compileErrors.length;i++){
	        		   resultStr += data.compileErrors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (!!data.compileWarnings && data.compileWarnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.compileWarnings.length;i++){
	        		   resultStr += data.compileWarnings[i];
	        		   resultStr += "<br/>" 
	        	   }
	        	   resultStr += "</span>";
        	   }
    		   if (!!resultStr) $("#generateResults").html(resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    }).done(function(data){
    	retVal = data.success;
	});
	return retVal;
}

function updateProject(ignoreAlert){
    if($('#projectform').form('validate')||ignoreAlert){    
		$("#generateResults").html("");
		var dbName = $("#dbname").val();
		var dbType = $("#dbtype").val();
		if (!!dbType &&(dbType == "postgresql"|| dbType == "pgsql")) {
			dbName = dbName.toLowerCase();
			$("#dbname").textbox("setValue",dbName)
		}
		$.ajax({
	        type: "post",
	        async:false,
	        url: "../facade/excelWizardFacade",
	        data: {command:"updateProject",
	        	fileName:$("#fileName").val(),
	        	project:$("#project").val(),
	        	packagetoken:$("#packagetoken").val(),
	        	dbprefix:$("#dbprefix").val(),
	        	dbname:dbName,
	        	dbusername:$("#dbusername").val(),
	        	dbpassword:$("#dbpassword").val(),
	        	dbtype:dbType,
	        	technicalstack:$("#technicalstack").val(),
	        	title:$("#title").val(),
	        	subtitle:$("#subtitle").val(),
	        	footer:$("#footer").val(),
	        	crossorigin:$("#crossorigin").val(),
	        	resolution:$("#resolution").val(),
	        	domainsuffix:$("#domainsuffix").val(),
	        	daosuffix:$("#daosuffix").val(),
	        	daoimplsuffix:$("#daoimplsuffix").val(),
	        	servicesuffix:$("#servicesuffix").val(),
	        	serviceimplsuffix:$("#serviceimplsuffix").val(),
	        	controllersuffix:$("#controllersuffix").val(),
	        	domainnamingsuffix:$("#domainnamingsuffix").val(),
	        	controllernamingsuffix:$("#controllernamingsuffix").val(),
	        	language:$("#language").val(),
	        	schema:$("#schema").val(),
	        	frontbaseapi:$("#frontbaseapi").val(),
	        	frontendUi:$("#frontendUi").val(),
	        	backendUi:$("#backendUi").val(),
	        	computerlanguage:$("#computerlanguage").val()
	       	},
	        dataType: 'json',
	        success: function(data, textStatus) {
				debugger;
				if (ignoreAlert == false && data.success == true){
					$.messager.alert("信息", "项目更新成功，欢迎使用！");
				}
	        },
	        complete : function(XMLHttpRequest, textStatus) {
	        
			},
			error : function(XMLHttpRequest,textStatus,errorThrown) {
				//alert("Error:"+textStatus);
				//alert(errorThrown.toString());
			}
	    });	
    }else{
    	 $.messager.alert("信息", "未通过校验，请检查设置！");
    	return;
    }
	$("#generateResults").html("");
	var dbName = $("#dbname").val();
	var dbType = $("#dbtype").val();
	if (!!dbType &&(dbType == "postgresql"|| dbType == "pgsql")) {
		dbName = dbName.toLowerCase();
		$("#dbname").textbox("setValue",dbName)
	}
	$.ajax({
        type: "post",
        async:false,
        url: "../facade/excelWizardFacade",
        data: {command:"updateProject",
        	fileName:$("#fileName").val(),
        	project:$("#project").val(),
        	packagetoken:$("#packagetoken").val(),
        	dbprefix:$("#dbprefix").val(),
        	dbname:dbName,
        	dbusername:$("#dbusername").val(),
        	dbpassword:$("#dbpassword").val(),
        	dbtype:dbType,
        	technicalstack:$("#technicalstack").val(),
        	title:$("#title").val(),
        	subtitle:$("#subtitle").val(),
        	footer:$("#footer").val(),
        	crossorigin:$("#crossorigin").val(),
        	resolution:$("#resolution").val(),
        	domainsuffix:$("#domainsuffix").val(),
        	daosuffix:$("#daosuffix").val(),
        	daoimplsuffix:$("#daoimplsuffix").val(),
        	servicesuffix:$("#servicesuffix").val(),
        	serviceimplsuffix:$("#serviceimplsuffix").val(),
        	controllersuffix:$("#controllersuffix").val(),
        	domainnamingsuffix:$("#domainnamingsuffix").val(),
        	controllernamingsuffix:$("#controllernamingsuffix").val(),
        	language:$("#language").val(),
        	schema:$("#schema").val(),
        	frontbaseapi:$("#frontbaseapi").val(),
        	frontendUi:$("#frontendUi").val(),
        	backendUi:$("#backendUi").val(),
        	computerlanguage:$("#computerlanguage").val()
       	},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (ignoreAlert == false && data.success == true){
        	   $.messager.alert("信息", "项目更新成功，欢迎使用！");
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function createNewDomain(){
	updateProjectAndAllDomains();
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"createNewDomain",
        	plural:"",
       	},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   $.messager.alert("信息", "域对象新建成功，欢迎使用！");
        	   listServerData();
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function createNewEnum(){
	updateProjectAndAllDomains();
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"createNewEnum",
        	plural:"",
       	},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   $.messager.alert("信息", "枚举新建成功，欢迎使用！");
        	   listServerData();
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function createNewMtmCandidate(){
	updateProjectAndAllDomains();
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: { command:"createNewMtmCandidate"
			},
        dataType: 'json',
        success: function(data, textStatus) {
           if (data.success == true){
        	   $.messager.alert("信息", "多对多候选新建成功，欢迎使用！");
        	   listServerData();
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function validateDomain(serial){
	return $($("#domainsdiv").find(".domainForm").get(serial)).form('validate');
}

function updateDomain(serial,ignoreAlert){
	if($($("#domainsdiv").find(".domainForm").get(serial)).form('validate')||ignoreAlert==true){    
		$("#generateResults").html("");
		$.ajax({
	        type: "post",
	        url: "../facade/excelWizardFacade",
	        data: {command:"updateDomain",
	        	serial:serial,
	        	domain:$($("#domainsdiv").find(".domainForm").get(serial)).find("#domain").val(),
	        	plural:$($("#domainsdiv").find(".domainForm").get(serial)).find("#plural").val(),
	        	tableprefix:$($("#domainsdiv").find(".domainForm").get(serial)).find("#tableprefix").val(),        	
	        	domainlabel:$($("#domainsdiv").find(".domainForm").get(serial)).find("#domainlabel").val(),
	        	verbdenies:$($("#domainsdiv").find(".domainForm").get(serial)).find("#verbdenies").val()
	       	},
	        dataType: 'json',
	        async: false,
	        success: function(data, textStatus) {
						debugger;
	           if (ignoreAlert == true && data.success == true){
	        	   //listServerData();
	           }else if (ignoreAlert == false && data.success == true){
	        	   $.messager.alert("信息", "域对象更新成功，欢迎使用！");
	        	   listServerData();
	           }
	        },
	        complete : function(XMLHttpRequest, textStatus) {
	        
			},
			error : function(XMLHttpRequest,textStatus,errorThrown) {
				//alert("Error:"+textStatus);
				//alert(errorThrown.toString());
			}
	    });	
	}else{
		$.messager.alert("信息", "请正确设置域对象属性！");
	}
}

function downloadExcel(){
	updateProjectAndAllDomains();
	listServerData();
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: { ignoreWarning:$("#ignoreWarning").prop("checked"),
        	command:"downloadExcel"},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true&& data.mode == "downloadExcel"){
           		$("#generateResults").html("<strong>"+data.fileName+"</strong><a href=\"../source/"+data.fileName+"\">下载Excel模板</a>");
           		$.messager.alert("信息", "模板保存成功，欢迎下载使用！");
           }else if (data.success == false){
        	   var resultStr ="";
        	   if (!isBlank(data.compileErrors) && data.compileErrors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.compileErrors.length;i++){
	        		   resultStr += data.compileErrors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (!isBlank(data.compileWarnings) && data.compileWarnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.compileWarnings.length;i++){
	        		   resultStr += data.compileWarnings[i];
	        		   resultStr += "<br/>" 
	        	   }
	        	   resultStr += "</span>";
        	   }
    		   if (!!resultStr) $("#generateResults").html(resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function Write2Text(filename)
{
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	var f = fso.CreateTextFile(filename, true);
	for(var i=0;i<arr.length;i++)
	{
	f.write(arr[i])
	f.WriteBlankLines(1)
	}
	f.Close();
}

function readText(myfilename){
	$("#generateResults").html("");
	$.ajax({
        type: "get",
        url: "../facade/readSgsFileFacade",
        data: {filename:myfilename},
        dataType: 'text',
        success: function(data, textStatus) {
           if ( data != null & data!="")
           		$("#mycode").val(data);
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	 
}

function readDocs(myfilename){
	$.ajax({
        type: "post",
        url: "../facade/readDocsFileFacade",
        data: {filename:myfilename},
        dataType: 'text',
        success: function(data, textStatus) {
           if ( data != null & data!="")
           		$("#mycode").val(data);
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	 
}

function switchUrl(url){
	window.location.href=url;
}

function isBlank(val){
	if (val == undefined|| val == null || val == "" || val== "0" || val == 0) return true;
	else return false;
}

function hasDataDomains(serial) {
	var retVal = false;
	$.ajax({
        url: '../facade/findDomianWithSerialFacade',
        type: 'POST',
        async: false,
        dataType: 'json',
        data: {serial:serial},
       	success: function (data) {
       	if (data.success == true) {
				retVal = data.hasDataDomains;
           }
       }
   });

   return retVal;
}
function getCols(serial) {
     var columns = [];
     $.ajax({
         url: '../facade/findDomianWithSerialFacade',
         type: 'POST',
         async: false,
         dataType: 'json',
         data: {serial:serial},
        success: function (data) {
        	if (data.success == true && data.data != null && data.data.length > 0) {
            	columns = [];
                $.each(data.data, function (i, item) {
                    columns.push({ "field": item.fieldName, "title": item.fieldMeta,"label":item.fieldLabel,"fieldtype":item.fieldType,"fieldlength":item.fieldLength, "fixedName":item.fieldFixedName, "width": 100, editor: { type: 'stringbox' } });
                });
            }
        }
    });

    return columns;
}

function loadDataGrid(serial) {
	var cols = getCols(serial);
	var recordLineStart = 3;
	
	$($("#domainsdiv").find(".dg").get(serial)).datagrid({
		pageSize : 10,
		pageList : [ 10, 20, 50, 100 ],
		pagination : false,
		singleSelect : true,
		selectOnCheck : true,
		sortName : 'id',
		sortOrder : 'asc',
		url : '../facade/findDataDomiansWithDomainNameFacade',
		queryParams :{serial:serial},
		method : 'post',
		columns : [ cols ],  
		onSelect:function (rowIndex, rowData) {
			var dataLineStart = 3;
            if ($(this).datagrid('getData').rows.length<5) dataLineStart =3;
			else if ($(this).datagrid('getData').rows[4]["字段"]== "固定名字") dataLineStart=4;
			if (rowIndex<=dataLineStart){
	        	$(this).datagrid("clearSelections"); //取消所有选中项
	        }
		},
        onRowContextMenu: function (e, rowIndex, rowData) { //右键时触发事件
            //三个参数：e里面的内容很多，真心不明白，rowIndex就是当前点击时所在行的索引，rowData当前行的数据
            e.preventDefault(); //阻止浏览器捕获右键事件
            $(this).datagrid("clearSelections"); //取消所有选中项
            var dataLineStart = 3;
            if ($(this).datagrid('getData').rows.length<5) dataLineStart =3;
			else if ($(this).datagrid('getData').rows[4]["字段"]== "固定名字") dataLineStart=4;
            if (rowIndex>dataLineStart){
	            $(this).datagrid("selectRow", rowIndex); //根据索引选中该行
	            $("#menuform").find("#serial").val(serial);
	            $("#menuform").find("#index").val(rowIndex-dataLineStart-1);
	            $('#menu').menu('show', {
	                //显示右键菜单
	                left: e.pageX,//在鼠标点击处显示菜单
	                top: e.pageY
	            });
            }
            e.preventDefault();  //阻止浏览器自带的右键菜单弹出
        },

		onLoadSuccess : function(data) {
			insertMetaRows(serial);
		},		
	});

	$($("#domainsdiv").find(".dg").get(serial)).datagrid("load");
	//$.parser.parse($("#domainsdiv"));
}

function insertMetaRows(serial) {  
    $.ajax({
        url: '../facade/findDomianMetaWithSerialFacade',
        type: 'POST',
        async: false,
        dataType: 'json',
        data:{serial:serial},
       	success: function (data) {
           if (data != null && data.success ==true && data.data != null && data.data.length > 0) {
        	   $.each(data.data, function (i, item) {	        	  
	        	   $($("#domainsdiv").find(".dg").get(serial)).datagrid('insertRow',{
            		     index : i,
            		     row :item
            		});
               });
           }
       }
   });
}

function showWsetSepcial(serial){
	pureUpdateProjectAndAllDomains();
	$("#domainfieldsform").find("#serial").val(serial);
	$("#domainfieldsform").find(".fieldrow").remove();
	var cols = getCols(serial);
	//var myhasDataDomains = hasDataDomains(serial);
	if (cols == null || cols.length <= 1){
		$("#domainfieldsform").find("#domainiddeny").checkbox("uncheck");
		$("#domainfieldsform").find("#domainnamedeny").checkbox("uncheck");
		$("#domainfieldsform").find("#activefielddeny").checkbox("uncheck");
		$('#wsetSepecial').window('open');
		return;
	}
	//if (myhasDataDomains){
	//	$.messager.alert("信息", "域对象已有数据，请清空后才可以修改字段信息！");
	//	return;
	//}
	$("#domainfieldsform").find("#domainiddeny").checkbox("check");
	$("#domainfieldsform").find("#domainnamedeny").checkbox("check");
	$("#domainfieldsform").find("#activefielddeny").checkbox("check");
	$("#domainfieldsform").find("#domainid").textbox("setValue","");
	$("#domainfieldsform").find("#domainidlabel").textbox("setValue","");
	$("#domainfieldsform").find("#domainidfixedname").textbox("setValue","");
	$("#domainfieldsform").find("#domainname").textbox("setValue","");
	$("#domainfieldsform").find("#domainnamelabel").textbox("setValue","");
	$("#domainfieldsform").find("#domainnamefixedname").textbox("setValue","");
	$("#domainfieldsform").find("#activefield").textbox("setValue","");	
	$("#domainfieldsform").find("#activefieldlabel").textbox("setValue","");
	$("#domainfieldsform").find("#activefieldfixedname").textbox("setValue","");
	
	$("#domainfieldsform").find("#domainidtype").textbox("setValue","Long");
	$("#domainfieldsform").find("#domainnametype").textbox("setValue","String");
	$("#domainfieldsform").find("#activefieldtype").textbox("setValue","Boolean");
	var myindex = 0;
	for (var i =0;i<cols.length;i++){
		 if (cols[i].title=="domainid"){
			$("#domainfieldsform").find("#domainid").textbox("setValue",cols[i].field);
			$("#domainfieldsform").find("#domainidtype").textbox("setValue",cols[i].fieldtype);
			$("#domainfieldsform").find("#domainidlabel").textbox("setValue",cols[i].label);
			$("#domainfieldsform").find("#domainidfixedname").textbox("setValue",cols[i].fixedName);
			$("#domainfieldsform").find("#domainiddeny").checkbox("uncheck");
		}else if (cols[i].title=="domainname"){
			$("#domainfieldsform").find("#domainname").textbox("setValue",cols[i].field);
			$("#domainfieldsform").find("#domainnametype").textbox("setValue",cols[i].fieldtype);
			$("#domainfieldsform").find("#domainnamelabel").textbox("setValue",cols[i].label);
			$("#domainfieldsform").find("#domainnamefixedname").textbox("setValue",cols[i].fixedName);
			$("#domainfieldsform").find("#domainnamedeny").checkbox("uncheck");
		}else if (cols[i].title=="activefield"){
			$("#domainfieldsform").find("#activefield").textbox("setValue",cols[i].field);
			$("#domainfieldsform").find("#activefieldtype").textbox("setValue",cols[i].fieldtype);
			$("#domainfieldsform").find("#activefieldlabel").textbox("setValue",cols[i].label);
			$("#domainfieldsform").find("#activefieldfixedname").textbox("setValue",cols[i].fixedName);
			$("#domainfieldsform").find("#activefielddeny").checkbox("uncheck");
		}else{
			if (!isBlank(cols[i].title)&&cols[i].title=="元字段类型") continue;
			addFieldRow();
			$.parser.parse($("#domainfieldsform").find(".fieldrow:last"));
			$($("#domainfieldsform").find(".fieldcatlog").get(myindex)).combobox("setValue",cols[i].title);
			$($("#domainfieldsform").find(".field").get(myindex)).textbox("setValue",cols[i].field);
			$($("#domainfieldsform").find(".fieldoriginalcatlog").get(myindex)).val(cols[i].title);
			$($("#domainfieldsform").find(".fieldoriginalname").get(myindex)).val(cols[i].field);
			$($("#domainfieldsform").find(".fieldtype").get(myindex)).combobox("setValue",cols[i].fieldtype);
			$($("#domainfieldsform").find(".fieldlength").get(myindex)).textbox("setValue",cols[i].fieldlength);
			$($("#domainfieldsform").find(".fieldlabel").get(myindex)).textbox("setValue",cols[i].label);
			$($("#domainfieldsform").find(".fieldfixedname").get(myindex)).textbox("setValue",cols[i].fixedName);
			myindex++;
		}
	}
	//$.parser.parse($("#domainfieldsform"));
	$('#domainfieldsform').find("#serial").val(serial);	
	$('#wsetSepecial').window('open'); // open a window
}

function setupDomainFields(serial){
	var fieldoriginalcatlog = [];
	if (!isBlank($("#domainfieldsform").find(".fieldoriginalcatlog"))) {
		$("#domainfieldsform").find(".fieldoriginalcatlog").each(
			function(){fieldoriginalcatlog.push($(this).val())})
	}
	var fieldoriginalname = [];
	if (!isBlank($("#domainfieldsform").find(".fieldoriginalname"))) {
		$("#domainfieldsform").find(".fieldoriginalname").each(
			function(){fieldoriginalname.push($(this).val())})
	}
	var fieldcatlog = [];
	if (!isBlank($("#domainfieldsform").find(".fieldcatlog"))) {
		$("#domainfieldsform").find(".fieldcatlog").each(
			function(){fieldcatlog.push($(this).val())})
	}
	var field = [];
	if (!isBlank($("#domainfieldsform").find(".field"))) {
		$("#domainfieldsform").find(".field").each(
			function(){field.push($(this).val())})
	}
	var fieldtype = [];
	if (!isBlank($("#domainfieldsform").find(".fieldtype"))) {
		$("#domainfieldsform").find(".fieldtype").each(
			function(){fieldtype.push($(this).val())})
	}
	var fieldlength = [];
	if (!isBlank($("#domainfieldsform").find(".fieldlength"))) {
		$("#domainfieldsform").find(".fieldlength").each(
			function(){fieldlength.push($(this).val())})
	}
	var fieldlabel = [];
	if (!isBlank($("#domainfieldsform").find(".fieldlabel"))) {
		$("#domainfieldsform").find(".fieldlabel").each(
			function(){fieldlabel.push($(this).val())})
	}
	var fieldfixedname = [];
	if (!isBlank($("#domainfieldsform").find(".fieldfixedname"))) {
		$("#domainfieldsform").find(".fieldfixedname").each(
			function(){fieldfixedname.push($(this).val())})
	}
	$.ajax({
        type: "post",
        url: "../facade/updateDomainFieldsWithSerialFacade",
        data: {serial:serial,
        	domainid:$("#domainfieldsform").find("#domainid").val(),
        	domainidtype:$("#domainfieldsform").find("#domainidtype").val(),
        	domainidlength:$("#domainfieldsform").find("#domainidlength").val(),
        	domainidlabel:$("#domainfieldsform").find("#domainidlabel").val(),
        	domainidfixedname:$("#domainfieldsform").find("#domainidfixedname").val(),
        	domainiddeny:$("#domainfieldsform").find("#domainiddeny").checkbox("options").checked,
        	domainname:$("#domainfieldsform").find("#domainname").val(),
        	domainnametype:$("#domainfieldsform").find("#domainnametype").val(),
        	domainnamelength:$("#domainfieldsform").find("#domainnamelength").val(),
        	domainnamelabel:$("#domainfieldsform").find("#domainnamelabel").val(),
        	domainnamefixedname:$("#domainfieldsform").find("#domainnamefixedname").val(),
        	domainnamedeny:$("#domainfieldsform").find("#domainnamedeny").checkbox("options").checked,
        	activefield:$("#domainfieldsform").find("#activefield").val(),
        	activefieldtype:$("#domainfieldsform").find("#activefieldtype").val(),
        	activefieldlength:$("#domainfieldsform").find("#activefieldlength").val(),
        	activefieldlabel:$("#domainfieldsform").find("#activefieldlabel").val(),
        	activefieldfixedname:$("#domainfieldsform").find("#activefieldfixedname").val(),
        	activefielddeny:$("#domainfieldsform").find("#activefielddeny").checkbox("options").checked,
        	
        	fieldoriginalcatlog:fieldoriginalcatlog,
        	fieldoriginalname:fieldoriginalname,
        	fieldcatlog:fieldcatlog,
        	field:field,
        	fieldtype:fieldtype,
        	fieldlength:fieldlength,
        	fieldlabel:fieldlabel,
        	fieldfixedname:fieldfixedname
       	},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   $.messager.alert("信息", "域对象字段设置成功，欢迎使用！");
        	   loadDataGrid(serial); 
        	   $('#wsetSepecial').window('close');
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function listProjectDomainNames(){
	var mydata = [];
	$.ajax({
        type: "post",
        url: "../facade/listDomianNamesFacade",
       	async:false,
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
               $.each(data.data, function (i, item) {
            	   mydata.push({ "value": item , "label": item});
               });
			   return mydata;
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
	return mydata;
}

function changeCategory(control){
	var cate = $(control).val();
	if (cate=="dropdown"||cate=="manytomany"){
		var data  = listProjectDomainNames();
		$(control).parents("tr").find(".fieldtype").combobox("setValue","");
		$(control).parents("tr").find(".fieldtype").combobox("loadData", data);
	}else if (cate == "field"){
		var data;
		data = [{value: 'Long',label: 'Long'},{value: 'Integer',label: 'Integer'},{value: 'Double',label: 'Double'},{value: 'Float',label: 'Float'},{value: 'String',label: 'String'},{value: 'Boolean',label: 'Boolean'},{value: 'image',label: 'image'},{value: 'date',label: 'date'},{value: 'datetime',label: 'datetime'}];
		$(control).parents("tr").find(".fieldtype").combobox("setValue","");
		$(control).parents("tr").find(".fieldtype").combobox("loadData", data);
	}
}

function loadDomains(control){
	var data  = listProjectDomainNames();
	$(control).parents("table").find(".masterName").combobox("loadData", data);
	$(control).parents("table").find(".slaveName").combobox("loadData", data);
}

function addFieldRow(){
	var row = '<tr class="fieldrow"><td><select id="fieldcatlog" class="easyui-combobox plain fieldcatlog" name="fieldcatlog"  style="width:80px" data-options="onChange:function(){changeCategory(this);}"><option value="field">field</option><option value="dropdown">dropdown</option><option value="manytomany">manytomany</option></select></td><td><input type="hidden" class="fieldoriginalcatlog" id="fieldoriginalcatlog" name="fieldoriginalcatlog"><input type="hidden" class="fieldoriginalname" id="fieldoriginalname" name="fieldoriginalname"><input type="text" class="easyui-textbox plain field"  id="field" name="field"></input></td>'+
	'<td><input type="text" class="easyui-combobox plain fieldtype"  id="fieldtype" name="fieldtype" data-options="valueField: \'value\',textField: \'label\', data: [{value: \'Long\',label: \'Long\'},{value: \'Integer\',label: \'Integer\'},{value: \'Double\',label: \'Double\'},{value: \'Float\',label: \'Float\'},{value: \'String\',label: \'String\'},{value: \'Boolean\',label: \'Boolean\'},{value: \'image\',label: \'image\'},{value: \'date\',label: \'date\'},{value: \'datetime\',label: \'datetime\'}]"/></td>'+
	'<td><input type="text" class="easyui-textbox plain fieldlength"  id="fieldlength" name="fieldlength"></input></td>'+
	'<td><input type="text" class="easyui-textbox plain fieldlabel"  id="fieldlabel" name="fieldlabel" value=""></input></td>'+
	'<td><input type="text" class="easyui-textbox plain fieldfixedname"  id="fieldfixedname" name="fieldfixedname" value=""></input></td>'+	
	'<td style="white-space: nowrap;"><select id="metatype" class="easyui-combobox plain metatype" name="metatype" style="width:100px"><option value="normal">普通字段</option><option value="domainid">domainid</option><option value="domainname">domainname</option><option value="activefield">activefield</option></select>' +
	'<a href="javascript:void(0)" class="easyui-linkbutton" id="updateFieldBtn" name="updateFieldBtn" onclick="updateFieldRow(this)">更新</a>' +
	'<a href="javascript:void(0)" class="easyui-linkbutton" id="deleteFieldBtn" name="deleteFieldBtn" onclick="deleteFieldRow(this)">删除</a></td></tr>';
	$("#domainfieldsform").find("#fieldsBody").append(row);
	$.parser.parse($("#domainfieldsform").find(".fieldrow:last"));
}

function addDataDomainFieldRow(fieldtype){
	var row0 = '<tr class="fieldrow"><td><select id="fieldcatlog" class="easyui-combobox plain fieldcatlog" name="fieldcatlog" style="width:80px"><option value="field">field</option><option value="dropdown">dropdown</option><option value="manytomany">manytomany</option></select></td><td><input type="text" class="easyui-textbox plain fieldname" id="fieldname" name="fieldname" value=""></input></td>'+
	'<td><input type="text" class="easyui-textbox plain fieldlabel"  id="fieldlabel" name="fieldlabel" value=""></input></td>'+
	'<td><input type="text" class="easyui-textbox plain fieldfixedname"  id="fieldfixedname" name="fieldfixedname" value=""></input></td>';
	if (fieldtype == 'date') {
		row0 +=	'<td><input type="text" class="easyui-datebox plain fieldvalue"  id="fieldvalue" name="fieldvalue" value=""></input></td>';
	}else if (fieldtype == 'datetime') {
		row0 +=	'<td><input type="text" class="easyui-datetimebox plain fieldvalue"  id="fieldvalue" name="fieldvalue" value=""></input></td>';
	}else {
		row0 +=	'<td><input type="text" class="easyui-textbox plain fieldvalue"  id="fieldvalue" name="fieldvalue" value=""></input></td>';
	}
	row0 +=	'<td></td></tr>';
	$("#datadomainfieldsform").find("#fieldsBody").append(row0);
}

function addUpdateDataDomainFieldRow(fieldtype){
	var row0 = '<tr class="fieldrow"><td><select id="fieldcatlog" class="easyui-combobox plain fieldcatlog" name="fieldcatlog" style="width:80px"><option value="field">field</option><option value="dropdown">dropdown</option><option value="manytomany">manytomany</option></select></td><td><input type="text" class="easyui-textbox plain fieldname" id="fieldname" name="fieldname" value=""></input></td>'+
	'<td><input type="text" class="easyui-textbox plain fieldlabel"  id="fieldlabel" name="fieldlabel" value=""></input></td>'+
	'<td><input type="text" class="easyui-textbox plain fieldfixedname"  id="fieldfixedname" name="fieldfixedname" value=""></input></td>';
	if (fieldtype == 'date'){
		row0 += '<td><input type="text" class="easyui-datebox plain fieldvalue"  id="fieldvalue" name="fieldvalue" value=""></input></td>';
	} else if (fieldtype == 'datetime'){
		row0 += '<td><input type="text" class="easyui-datetimebox plain fieldvalue"  id="fieldvalue" name="fieldvalue" value=""></input></td>';
	}else {
		row0 += '<td><input type="text" class="easyui-textbox plain fieldvalue"  id="fieldvalue" name="fieldvalue" value=""></input></td>';
	}
	'<td></td></tr>';
	$("#updatedatadomainform").find("#fieldsBody").append(row0);
}

function deleteFieldRow(obj){
	var serial = $('#domainfieldsform').find('#serial').val();
	var originalcatlog = $($(obj).parents("tr")).find('input[name="fieldoriginalcatlog"]').val();
	var originalname = $(obj).parents("tr").find('input[name="fieldoriginalname"]').val();
	//alert(serial + ":"+ originalcatlog +":"+originalname);
	$.ajax({
        url: '../facade/deleteDomainFieldWithSerialCatlogNameFacade',
        type: 'POST',
        async: false,
        dataType: 'json',
        data: {serial:serial,originalcatlog:originalcatlog,originalname:originalname},
       	success: function (data) {
       		if (data.success == true){
    	   		$(obj).parents("tr").remove();
       		}
       }
   });	
}

function updateFieldRow(obj){	
	var serial = $('#domainfieldsform').find('#serial').val();
	var metatype = $($(obj).parents("tr")).find('input[name="metatype"]').val();
	var originalcatlog = $($(obj).parents("tr")).find('input[name="fieldoriginalcatlog"]').val();
	var originalname = $(obj).parents("tr").find('input[name="fieldoriginalname"]').val();
	var fieldcatlog = $(obj).parents("tr").find('.fieldcatlog').val();
	var fieldname = $(obj).parents("tr").find('.field').val();
	var fieldtype = $(obj).parents("tr").find('.fieldtype').val();
	var fieldlength = $(obj).parents("tr").find('.fieldlength').val();	
	var fieldlabel = $(obj).parents("tr").find('.fieldlabel').val();	
	var fieldfixedname = $(obj).parents("tr").find('.fieldfixedname').val();
	if (metatype == "domainid"){
		if (fieldtype=="Long"){
			setupDomainIdField(serial,originalcatlog,originalname,fieldname,fieldlabel,fieldfixedname);
			return;
		}
		$.messager.alert("错误", "域对象序号字段更新失败。");
		return;
	} else if (metatype == "domainname"){
		if (fieldtype=="String"){
			setupDomainNameField(serial,originalcatlog,originalname,fieldname,fieldlabel,fieldfixedname,fieldlength);
			return;
		}
		$.messager.alert("错误", "域对象名字字段更新失败。");
		return;
	} else if (metatype == "activefield"){
		if (fieldtype=="Boolean"){
			setupDomainActiveField(serial,originalcatlog,originalname,fieldname,fieldlabel,fieldfixedname);
			return;
		}
		$.messager.alert("错误", "域对象活跃字段更新失败。");
		return;
	}
	$.ajax({
        url: '../facade/updateDomainFieldWithSerialFacade',
        type: 'POST',
        async: false,
        dataType: 'json',
        data: {serial:serial,
        		originalcatlog:originalcatlog,
        		originalname:originalname,
        		fieldcatlog:fieldcatlog,
        		fieldname:fieldname,
        		fieldtype:fieldtype,
        		fieldlength:fieldlength,
        		fieldlabel:fieldlabel,
        		fieldfixedname:fieldfixedname
        },
       	success: function (data) {
       		if (data.success == true){
       			$.messager.alert("信息", "字段更新成功，欢迎使用！");
       		}
       }
   });	
}

function setupDomainIdField(serial,originalcatlog,originalname,fieldname,fieldlabel,fieldfixedname){	
	$.ajax({
        url: '../facade/setupDomainIdFieldWithSerialFacade',
        type: 'POST',
        async: false,
        dataType: 'json',
        data: {serial:serial,
        		originalcatlog:originalcatlog,
        		originalname:originalname,
	       		fieldname:fieldname,
         		fieldlabel:fieldlabel,
        		fieldfixedname:fieldfixedname
        },
       	success: function (data) {
       		if (data.success == true){
       			$.messager.alert("信息", "字段更新成功，欢迎使用！");
       			showWsetSepcial(serial);
       		}
       }
   });	
}

function setupDomainNameField(serial,originalcatlog,originalname,fieldname,fieldlabel,fieldfixedname){	
	$.ajax({
        url: '../facade/setupDomainNameFieldWithSerialFacade',
        type: 'POST',
        async: false,
        dataType: 'json',
        data: {serial:serial,
        		originalcatlog:originalcatlog,
        		originalname:originalname,
	       		fieldname:fieldname,
         		fieldlabel:fieldlabel,
        		fieldfixedname:fieldfixedname
        },
       	success: function (data) {
       		if (data.success == true){
       			$.messager.alert("信息", "字段更新成功，欢迎使用！");   
       			refleshWsetSepcial(serial);
       		}
       }
   });	
}


function setupDomainActiveField(serial,originalcatlog,originalname,fieldname,fieldlabel,fieldfixedname){	
	$.ajax({
        url: '../facade/setupDomainActiveFieldWithSerialFacade',
        type: 'POST',
        async: false,
        dataType: 'json',
        data: {serial:serial,
        		originalcatlog:originalcatlog,
        		originalname:originalname,
	       		fieldname:fieldname,
         		fieldlabel:fieldlabel,
        		fieldfixedname:fieldfixedname
        },
       	success: function (data) {
       		if (data.success == true){
       			$.messager.alert("信息", "字段更新成功，欢迎使用！");   
       			refleshWsetSepcial(serial);
       		}
       }
   });	
}

function initDataDomainFields(serial) {
	$("#datadomainfieldsform").find(".fieldrow").remove();
	var cols = getCols(serial);
	$("#datadomainfieldsform").find("#domainiddeny").checkbox("check");
	$("#datadomainfieldsform").find("#domainnamedeny").checkbox("check");
	$("#datadomainfieldsform").find("#activefielddeny").checkbox("check");
	$("#datadomainfieldsform").find("#domainid").textbox("setValue","");
	$("#datadomainfieldsform").find("#domainidlabel").textbox("setValue","");
	$("#datadomainfieldsform").find("#domainidfixedname").textbox("setValue","");
	$("#datadomainfieldsform").find("#domainname").textbox("setValue","");
	$("#datadomainfieldsform").find("#domainnamelabel").textbox("setValue","");
	$("#datadomainfieldsform").find("#domainnamefixedname").textbox("setValue","");
	$("#datadomainfieldsform").find("#activefield").textbox("setValue","");	
	$("#datadomainfieldsform").find("#activefieldlabel").textbox("setValue","");
	$("#datadomainfieldsform").find("#activefieldfixedname").textbox("setValue","");
	var myindex = 0;
	for (var i =0;i<cols.length;i++){
		 if (cols[i].title=="domainid"){
			$("#datadomainfieldsform").find("#domainid").textbox("setValue",cols[i].field);
			$("#datadomainfieldsform").find("#domainidlabel").textbox("setValue",cols[i].label);
			$("#datadomainfieldsform").find("#domainidfixedname").textbox("setValue",cols[i].fixedName);
			$("#datadomainfieldsform").find("#domainiddeny").checkbox("uncheck");
		}else if (cols[i].title=="domainname"){
			$("#datadomainfieldsform").find("#domainname").textbox("setValue",cols[i].field);
			$("#datadomainfieldsform").find("#domainnamelabel").textbox("setValue",cols[i].label);
			$("#datadomainfieldsform").find("#domainnamefixedname").textbox("setValue",cols[i].fixedName);
			$("#datadomainfieldsform").find("#domainnamedeny").checkbox("uncheck");
		}else if (cols[i].title=="activefield"){
			$("#datadomainfieldsform").find("#activefield").textbox("setValue",cols[i].field);
			$("#datadomainfieldsform").find("#activefieldlabel").textbox("setValue",cols[i].label);
			$("#datadomainfieldsform").find("#activefieldfixedname").textbox("setValue",cols[i].fixedName);
			$("#datadomainfieldsform").find("#activefielddeny").checkbox("uncheck");
		}else{
			if (!isBlank(cols[i].title)&&cols[i].title=="元字段类型") continue;
			addDataDomainFieldRow(cols[i].fieldtype);
			$.parser.parse($("#datadomainfieldsform").find(".fieldrow:last"));
			$($("#datadomainfieldsform").find(".fieldcatlog").get(myindex)).combobox("setValue",cols[i].title);
			$($("#datadomainfieldsform").find(".fieldname").get(myindex)).textbox("setValue",cols[i].field);
			$($("#datadomainfieldsform").find(".fieldlabel").get(myindex)).textbox("setValue",cols[i].label);
			$($("#datadomainfieldsform").find(".fieldfixedname").get(myindex)).textbox("setValue",cols[i].fixedName);
			myindex++;
		}
	}
	//$.parser.parse($("#datadomainfieldsform"));
	$('#datadomainfieldsform').find("#serial").val(serial);
	$('#waddDataDomain').window('open'); 
}

function getDataDomain(serial,index){
	var columns = [];
    $.ajax({
        url: '../facade/findDataDomianWithSerialIndexFacade',
        type: 'POST',
        async: false,
        dataType: 'json',
        data: {serial:serial,index:index},
       success: function (data) {
           if (data != null && data.length > 0) {
               $.each(data, function (i, item) {
                   columns.push({ "field": item.fieldName, "title": item.fieldMeta,"label":item.fieldLabel, "fixedName":item.fieldFixedName,"fieldType":item.fieldType,value:item.fieldvalue,"width": 100, editor: { type: 'stringbox' } });
               });
           }
       }
   });

   return columns;
}


function initUpdateDataDomain() {
	$("#updatedatadomainform").find(".fieldrow").remove();
	var serial = $("#menuform").find("#serial").val();
	var index = $("#menuform").find("#index").val();
	var cols = getDataDomain(serial,index);
	$("#updatedatadomainform").find("#domainiddeny").checkbox({checked: true});
	$("#updatedatadomainform").find("#domainnamedeny").checkbox({checked: true});
	$("#updatedatadomainform").find("#activefielddeny").checkbox({checked: true});
	$("#updatedatadomainform").find("#domainid").textbox("setValue","");
	$("#updatedatadomainform").find("#domainidlabel").textbox("setValue","");
	$("#updatedatadomainform").find("#domainidvalue").textbox("setValue","");
	$("#updatedatadomainform").find("#domainname").textbox("setValue","");
	$("#updatedatadomainform").find("#domainnamelabel").textbox("setValue","");
	$("#updatedatadomainform").find("#domainnamevalue").textbox("setValue","");
	$("#updatedatadomainform").find("#activefield").textbox("setValue","");	
	$("#updatedatadomainform").find("#activefieldlabel").textbox("setValue","");
	$("#updatedatadomainform").find("#activefieldvalue").textbox("setValue","");
	
	var myindex = 0;
	for (var i =0;i<cols.length;i++){
		 if (cols[i].title=="domainid"){
			$("#updatedatadomainform").find("#domainid").textbox("setValue",cols[i].field);
			$("#updatedatadomainform").find("#domainidlabel").textbox("setValue",cols[i].label);
			$("#updatedatadomainform").find("#domainidfixedname").textbox("setValue",cols[i].fixedName);
			$("#updatedatadomainform").find("#domainidvalue").textbox("setValue",cols[i].value);
			$("#updatedatadomainform").find("#domainiddeny").checkbox({checked: false});
		}else if (cols[i].title=="domainname"){
			$("#updatedatadomainform").find("#domainname").textbox("setValue",cols[i].field);
			$("#updatedatadomainform").find("#domainnamelabel").textbox("setValue",cols[i].label);
			$("#updatedatadomainform").find("#domainnamefixedname").textbox("setValue",cols[i].fixedName);
			$("#updatedatadomainform").find("#domainnamevalue").textbox("setValue",cols[i].value);
			$("#updatedatadomainform").find("#domainnamedeny").checkbox({checked: false});
		}else if (cols[i].title=="activefield"){
			$("#updatedatadomainform").find("#activefield").textbox("setValue",cols[i].field);
			$("#updatedatadomainform").find("#activefieldlabel").textbox("setValue",cols[i].label);
			$("#updatedatadomainform").find("#activefieldfixedname").textbox("setValue",cols[i].fixedName);
			$("#updatedatadomainform").find("#activefieldvalue").textbox("setValue",cols[i].value);
			$("#updatedatadomainform").find("#activefielddeny").checkbox({checked: false});
		}else{
			if (!isBlank(cols[i].title)&&cols[i].title=="元字段类型") continue;
			addUpdateDataDomainFieldRow(cols[i].fieldType);
			$.parser.parse($("#updatedatadomainform").find(".fieldrow:last"));
			$($("#updatedatadomainform").find(".fieldcatlog").get(myindex)).combobox("setValue",cols[i].title);
			$($("#updatedatadomainform").find(".fieldname").get(myindex)).textbox("setValue",cols[i].field);			
			$($("#updatedatadomainform").find(".fieldlabel").get(myindex)).textbox("setValue",cols[i].label);
			$($("#updatedatadomainform").find(".fieldfixedname").get(myindex)).textbox("setValue",cols[i].fixedName);
			$($("#updatedatadomainform").find(".fieldvalue").get(myindex)).textbox("setValue",cols[i].value);
			myindex++;
		}
	}
	//$.parser.parse($("#updatedatadomainform"));
	$("#updatedatadomainform").find("#serial").val(serial);
	$("#updatedatadomainform").find("#index").val(index);
	$('#wupdateDataDomain').window('open'); 
}

function getDomainFormContent(index){
	var content = '<div id="domainpanel" class="easyui-panel domainpanel" title="域对象" style="width:1180px;">'+
	'<div style="padding:10px 20px 20px 20px">'+
	'<form id="domainForm" class="domainForm" method="post"> <input type="hidden" id="isEnum" value="false">'+
	'<table cellpadding="5">'+
	'<tr><td class="banner">domain</td><td class="banner"><input  class="easyui-textbox" type="text" name="domain" id="domain"  data-options="required:true"/></td><td class="banner">plural</td><td class="banner"><input  class="easyui-textbox" type="text" name="plural" id="plural" data-options="required:false"/></td><td class="banner">tableprefix</td><td class="banner"><input  class="easyui-textbox" type="text" name="tableprefix" id="tableprefix" data-options="required:false"/></td></tr>'+
	'<tr><td class="banner">domainlabel</td><td class="banner"><input class="easyui-textbox" type="text" name="domainlabel" id="domainlabel" data-options="required:false"/></td><td class="banner">verbdenies</td><td colspan="3"><input  style="width:520px" class="easyui-textbox" type="text" name="verbdenies" id="verbdenies" data-options="required:false"/><a id="denyWizzardBtn" href="#" class="easyui-linkbutton" data-options="iconCls:\'icon-search\'" onclick="initDenyWizzard('+index+')"></a></td></tr>'+
	'</table>'+
	'</form>'+
	'<table id="dg" class="easyui-datagrid dg" title="域对象数据" style="width:1200px;height:320px" >'+
	'</table>'+
	'<div style="text-align:center;padding:5px">'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateDomain('+index+',false)">更新属性</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="showWsetSepcial('+index+')">字段编辑</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="initDataDomainFields('+index+')">新增数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="winitUpdateDataDomain('+index+')">编辑数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="switchToEnum('+index+')">切换为枚举</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="wdeleteDataDomain('+index+')">删除数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="wdeleteAllDataDomains('+index+')">删除全部数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="switchDomainToMtmCandidate('+index+')">转换为多对多候选</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteDomain('+index+')">删除域对象</a>'+
	'</div>'+
	'</div>'+
	'</div>'+
	'<br><br>';
	return content;
}

function getMtmCandidateFormContent(index){
	var content = '<div id="mtmcandidatepanel" class="easyui-panel mtmcandidatepanel" title="多对多候选" style="width:1180px;">'+
	'<div style="padding:10px 20px 20px 20px">'+
	'<form id="mtmCandidateForm" class="mtmCandidateForm" method="post">'+
	'<table cellpadding="5">'+
	'<tr><td class="banner">masterId</td><td class="banner"><input class="easyui-textbox" type="text" name="masterId" id="masterId" data-options="required:true, editable:false"/></td><td class="banner">master</td><td><input type="text" class="easyui-combobox plain masterName" id="masterName" name="masterName" data-options="value:\'\',valueField: \'value\',textField: \'label\', onSelect:function(record){ setupMtmCandidateMaster(record,'+index+') }"/></td><td class="banner">label</td><td><input  class="easyui-textbox" type="text" name="label" id="label"  data-options="required:false"/></td></tr>'+
	'<tr><td class="banner">slaveAliasId</td><td class="banner"><input class="easyui-textbox" type="text" name="slaveAliasId" id="slaveAliasId" data-options="required:true, onChange: function(value) { changeSlaveAliasId(value , '+index+') }"/></td><td class="banner">slave</td><td><input type="text" class="easyui-combobox plain slaveName" id="slaveName" name="slaveName" data-options="valueField: \'value\',textField: \'label\'"/></td><td>slaveAlias</td><td><input class="easyui-textbox" type="text" name="slaveAlias" id="slaveAlias" data-options="required:true, editable:false"/</td></tr>'+
	'</table>'+
	'</form>'+
	'<table id="mtmCandidateDg" class="easyui-datagrid mtmCandidateDg" title="多对多候选数据" style="width:1200px;height:320px" >'+
	'<thead>'+
	'<tr>'+
	'<th data-options="field:\'masterId\',width:240">主对象序号</th>'+
	'<th data-options="field:\'slaveIds\',width:400">从对象序号</th>'+
	'</tr>'+
	'</thead>'+
	'</table>'+
	'<div style="text-align:center;padding:5px">'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateMtmCandidate('+index+')">更新属性</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="showAddMtmCandidateData('+index+')">新增数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="showUpdateMtmCandidateData('+index+')">更新数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteMtmCandidateData('+index+')">删除数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteAllMtmCandidateData('+index+')">删除全部数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteMtmCandidate('+index+')">删除多对多候选</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="mtmCandidateToDomain('+index+')">转换为域对象</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="attachToDomain('+index+')">叠加至域对象</a>'+
	'</div>'+
	'</div>'+
	'</div>'+
	'<br><br>';
	return content;
}

function getEnumFormContent(index){
	var content = '<div id="domainpanel" class="easyui-panel domainpanel" title="枚举" style="width:1180px;">'+
	'<div style="padding:10px 20px 20px 20px">'+
	'<form id="domainForm" class="domainForm" method="post"> <input type="hidden" id="isEnum" value="true">'+
	'<table cellpadding="5">'+
	'<tr><td class="banner">domain</td><td class="banner"><input  class="easyui-textbox" type="text" name="domain" id="domain"  data-options="required:true"/></td><td class="banner">plural</td><td class="banner"><input  class="easyui-textbox" type="text" name="plural" id="plural" data-options="required:false"/></td><td class="banner">tableprefix</td><td class="banner"><input  class="easyui-textbox" type="text" name="tableprefix" id="tableprefix" data-options="required:false"/></td></tr>'+
	'<tr><td class="banner">domainlabel</td><td class="banner"><input class="easyui-textbox" type="text" name="domainlabel" id="domainlabel" data-options="required:false"/></td><td class="banner">verbdenies</td><td colspan="3"><input  style="width:520px" class="easyui-textbox" type="text" name="verbdenies" id="verbdenies" data-options="required:false"/><a id="denyWizzardBtn" href="#" class="easyui-linkbutton" data-options="iconCls:\'icon-search\'" onclick="initDenyWizzard('+index+')"></a></td></tr>'+
	'</table>'+
	'</form>'+
	'<table id="dg" class="easyui-datagrid dg" title="枚举数据" style="width:1200px;height:320px" >'+
	'</table>'+
	'<div style="text-align:center;padding:5px">'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateDomain('+index+',false)">更新属性</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="showWsetSepcial('+index+')">字段编辑</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="initDataDomainFields('+index+')">新增数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="winitUpdateDataDomain('+index+')">编辑数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="switchToDomain('+index+')">切换为域对象</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="wdeleteDataDomain('+index+')">删除数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="wdeleteAllDataDomains('+index+')">删除全部数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="switchDomainToMtmCandidate('+index+')">转换为多对多候选</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteDomain('+index+')">删除枚举</a>'+
	'</div>'+
	'</div>'+
	'</div>'+
	'<br><br>';
	return content;
}

function getSimpleAuthModuleFormContent(){
	var content = '<div id="modulepanel" class="easyui-panel modulepanel" title="SimpleAuth登录模块" style="width:1180px;">'+
	'<div style="padding:10px 20px 20px 20px">'+
	'<form id="moduleForm" class="moduleForm" method="post">'+
	'<table cellpadding="5">'+
	'<tr><td class="banner">module</td><td class="banner"><input  class="easyui-textbox" type="text" name="module" id="module"  data-options="required:true" value="SimpleAuth" readonly/></td></tr>'+
	'<tr><td class="banner">userdomain</td><td class="banner"><input class="easyui-textbox" type="text" name="userdomain" id="userdomain" data-options="required:false"/></td></tr>'+
	'<tr><td class="banner">roledomain</td><td class="banner"><input class="easyui-textbox" type="text" name="roledomain" id="roledomain" data-options="required:false"/></td></tr>'+
	'<tr><td class="banner">privilegedomain</td><td class="banner"><input class="easyui-textbox" type="text" name="privilegedomain" id="privilegedomain" data-options="required:false"/></td></tr>'+
	'</table>'+
	'</form>'+
	'<div style="text-align:center;padding:5px">'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateSimpleAuthModule(false)">保存</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearLoginData()">清洗登录数据</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteSimpleAuthModule()">删除</a>'+
	'</div>'+
	'</div>'+
	'</div>'+
	'<br><br>';
	return content;
}

function getParentChildLayoutFormContent(index){
	var content = '<div id="mylayoutpanel" class="easyui-panel mylayoutpanel" title="复杂版面" style="width:1180px;">'+
	'<div style="padding:10px 20px 20px 20px">'+
	'<form id="mylayoutForm" class="mylayoutForm" method="post">'+
	'<table cellpadding="5">'+
	'<tr><td class="banner">layout</td><td class="banner"><input type="text" style="width:280px;" class="easyui-combobox plain mylayout" id="mylayout" name="mylayout" data-options="valueField: \'value\',textField: \'label\', data: [{value: \'ParentChild\',label: \'ParentChild\'},{value: \'TreeGrid\',label: \'TreeGrid\'},{value: \'TreeParentChild\',label: \'TreeParentChild\'}]" value="ParentChild"/></td></tr>'+
	'<tr><td class="banner">parentdomain</td><td class="banner"><input class="easyui-textbox" type="text" name="parentdomain" id="parentdomain" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">childdomain</td><td class="banner"><input class="easyui-textbox" type="text" name="childdomain" id="childdomain" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">parentidfield</td><td class="banner"><input class="easyui-textbox" type="text" name="parentidfield" id="parentidfield" data-options="required:true"/></td></tr>'+
	'</table>'+
	'</form>'+
	'<div style="text-align:center;padding:5px">'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateParentChildLayout('+index+',false)">保存</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteLayout('+index+')">删除</a>'+
	'</div>'+
	'</div>'+
	'</div>'+
	'<br><br>';
	return content;
}

function getTreeGridLayoutFormContent(index){
	var content = '<div id="mylayoutpanel" class="easyui-panel mylayoutpanel" title="复杂版面" style="width:1180px;">'+
	'<div style="padding:10px 20px 20px 20px">'+
	'<form id="mylayoutForm" class="mylayoutForm" method="post">'+
	'<table cellpadding="5">'+
	'<tr><td class="banner">layout</td><td class="banner"><input type="text" style="width:280px;" class="easyui-combobox plain mylayout"  id="mylayout" name="mylayout" data-options="valueField: \'value\',textField: \'label\', data: [{value: \'ParentChild\',label: \'ParentChild\'},{value: \'TreeGrid\',label: \'TreeGrid\'},{value: \'TreeParentChild\',label: \'TreeParentChild\'}]" value="TreeGrid"/></td></tr>'+
	'<tr><td class="banner">treedomain</td><td class="banner"><input class="easyui-textbox" type="text" name="treedomain" id="treedomain" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">childdomain</td><td class="banner"><input class="easyui-textbox" type="text" name="childdomain" id="childdomain" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">innertreeparentidfield</td><td class="banner"><input class="easyui-textbox" type="text" name="innertreeparentidfield" id="innertreeparentidfield" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">parentidfield</td><td class="banner"><input class="easyui-textbox" type="text" name="parentidfield" id="parentidfield" data-options="required:true"/></td></tr>'+
	'</table>'+
	'</form>'+
	'<div style="text-align:center;padding:5px">'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateTreeGridLayout('+index+',false)">保存</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteLayout('+index+')">删除</a>'+
	'</div>'+
	'</div>'+
	'</div>'+
	'<br><br>';
	return content;
}


function getTreeParentChildLayoutFormContent(index){
	var content = '<div id="mylayoutpanel" class="easyui-panel mylayoutpanel" title="复杂版面" style="width:1180px;">'+
	'<div style="padding:10px 20px 20px 20px">'+
	'<form id="mylayoutForm" class="mylayoutForm" method="post">'+
	'<table cellpadding="5">'+
	'<tr><td class="banner">layout</td><td class="banner"><input type="text" style="width:280px;" class="easyui-combobox plain mylayout"  id="mylayout" name="mylayout" data-options="valueField: \'value\',textField: \'label\', data: [{value: \'ParentChild\',label: \'ParentChild\'},{value: \'TreeGrid\',label: \'TreeGrid\'},{value: \'TreeParentChild\',label: \'TreeParentChild\'}]" value="TreeParentChild"/></td></tr>'+
	'<tr><td class="banner">treedomain</td><td class="banner"><input class="easyui-textbox" type="text" name="treedomain" id="treedomain" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">parentdomain</td><td class="banner"><input class="easyui-textbox" type="text" name="parentdomain" id="parentdomain" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">childdomain</td><td class="banner"><input class="easyui-textbox" type="text" name="childdomain" id="childdomain" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">innertreeparentidfield</td><td class="banner"><input class="easyui-textbox" type="text" name="innertreeparentidfield" id="innertreeparentidfield" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">treeparentidfield</td><td class="banner"><input class="easyui-textbox" type="text" name="treeparentidfield" id="treeparentidfield" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">parentidfield</td><td class="banner"><input class="easyui-textbox" type="text" name="parentidfield" id="parentidfield" data-options="required:true"/></td></tr>'+
	'</table>'+
	'</form>'+
	'<div style="text-align:center;padding:5px">'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateTreeParentChildLayout('+index+',false)">保存</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteLayout('+index+')">删除</a>'+
	'</div>'+
	'</div>'+
	'</div>'+
	'<br><br>';
	return content;
}

function getEchartsReportFormContent(index){
	var content = '<div id="reportpanel" class="easyui-panel reportpanel" title="图形报表" style="width:1180px;">'+
	'<div style="padding:10px 20px 20px 20px">'+
	'<form id="reportForm" class="reportForm" method="post">'+
	'<table cellpadding="5">'+
	'<tr><td class="banner">report</td><td class="banner"><input type="text" style="width:280px;" class="easyui-combobox plain report"  id="report" name="report" data-options="valueField: \'value\',textField: \'label\', data: [{value: \'EchartsReport\',label: \'EchartsReport\'},{value: \'EchartsGridReport\',label: \'EchartsGridReport\'},{value: \'EchartsCompareGridReport\',label: \'EchartsCompareGridReport\'}]"/></td></tr>'+
	'<tr><td class="banner">reportdomain</td><td class="banner"><input class="easyui-textbox" type="text" name="reportdomain" id="reportdomain" data-options="required:false"/></td></tr>'+
	'<tr><td class="banner">xaxisfields</td><td class="banner"><input class="easyui-textbox" type="text" name="xaxisfields" id="xaxisfields" data-options="required:false"/></td></tr>'+
	'<tr><td class="banner">yname</td><td class="banner"><input class="easyui-textbox" type="text" name="yname" id="yname" data-options="required:false"/></td></tr>'+
	'</table>'+
	'</form>'+
	'<div style="text-align:center;padding:5px">'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateEchartsReport('+index+',false)">保存</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteReport('+index+')">删除</a>'+
	'</div>'+
	'</div>'+
	'</div>'+
	'<br><br>';
	return content;
}

function getEchartsGridReportFormContent(index){
	var content = '<div id="reportpanel" class="easyui-panel reportpanel" title="图形报表" style="width:1180px;">'+
	'<div style="padding:10px 20px 20px 20px">'+
	'<form id="reportForm" class="reportForm" method="post">'+
	'<table cellpadding="5">'+
	'<tr><td class="banner">report</td><td class="banner"><input type="text" style="width:280px;" class="easyui-combobox plain report"  id="report" name="report" data-options="valueField: \'value\',textField: \'label\', data: [{value: \'EchartsReport\',label: \'EchartsReport\'},{value: \'EchartsGridReport\',label: \'EchartsGridReport\'},{value: \'EchartsCompareGridReport\',label: \'EchartsCompareGridReport\'}]"/></td></tr>'+
	'<tr><td class="banner">reportdomain</td><td class="banner"><input class="easyui-textbox" type="text" name="reportdomain" id="reportdomain" data-options="required:false"/></td></tr>'+
	'<tr><td class="banner">xaxisfields</td><td class="banner"><input class="easyui-textbox" type="text" name="xaxisfields" id="xaxisfields" data-options="required:false"/></td></tr>'+
	'<tr><td class="banner">yname</td><td class="banner"><input class="easyui-textbox" type="text" name="yname" id="yname" data-options="required:false"/></td></tr>'+
	'</table>'+
	'</form>'+
	'<div style="text-align:center;padding:5px">'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateEchartsGridReport('+index+',false)">保存</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteReport('+index+')">删除</a>'+
	'</div>'+
	'</div>'+
	'</div>'+
	'<br><br>';
	return content;
}

function getEchartsCompareGridReportFormContent(index){
	var content = '<div id="reportpanel" class="easyui-panel reportpanel" title="图形报表" style="width:1180px;">'+
	'<div style="padding:10px 20px 20px 20px">'+
	'<form id="reportForm" class="reportForm" method="post">'+
	'<table cellpadding="5">'+
	'<tr><td class="banner">report</td><td class="banner"><input type="text" style="width:280px;" class="easyui-combobox plain report"  id="report" name="report" data-options="valueField: \'value\',textField: \'label\', data: [{value: \'EchartsReport\',label: \'EchartsReport\'},{value: \'EchartsGridReport\',label: \'EchartsGridReport\'},{value: \'EchartsCompareGridReport\',label: \'EchartsCompareGridReport\'}]"/></td></tr>'+
	'<tr><td class="banner">plandomain</td><td class="banner"><input class="easyui-textbox" type="text" name="plandomain" id="plandomain" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">planxaxisfields</td><td class="banner"><input class="easyui-textbox" type="text" name="planxaxisfields" id="planxaxisfields" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">planyname</td><td class="banner"><input class="easyui-textbox" type="text" name="planyname" id="planyname" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">actiondomain</td><td class="banner"><input class="easyui-textbox" type="text" name="actiondomain" id="actiondomain" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">actionxaxisfields</td><td class="banner"><input class="easyui-textbox" type="text" name="actionxaxisfields" id="actionxaxisfields" data-options="required:true"/></td></tr>'+
	'<tr><td class="banner">actionyname</td><td class="banner"><input class="easyui-textbox" type="text" name="actionyname" id="actionyname" data-options="required:true"/></td></tr>'+
	'</table>'+
	'</form>'+
	'<div style="text-align:center;padding:5px">'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="updateEchartsCompareGridReport('+index+',false)">保存</a>'+
	'<a href="javascript:void(0)" class="easyui-linkbutton" onclick="deleteReport('+index+')">删除</a>'+
	'</div>'+
	'</div>'+
	'</div>'+
	'<br><br>';
	return content;
}

function addDomainForms(domains){
	for (var i=0;i<domains.length;i++){
		if (domains[i].isEnum == "false"){
			$(getDomainFormContent(i)).appendTo("#domainsdiv");
		} else {
			$(getEnumFormContent(i)).appendTo("#domainsdiv");
		}
	}
	$.parser.parse($("#domainsdiv"));
}

function addMtmCandidates(count){
	for (var i=0;i<count;i++){
		$(getMtmCandidateFormContent(i)).appendTo("#domainsdiv");
	}
	$.parser.parse($("#domainsdiv"));
}

function addSimpleAuthModuleForm(){
	$(getSimpleAuthModuleFormContent()).appendTo("#domainsdiv");
	$.parser.parse($("#domainsdiv"));
}

function addParentChildLayoutForm(index){
	$(getParentChildLayoutFormContent(index)).appendTo("#domainsdiv");
	$.parser.parse($("#domainsdiv"));
	$(".mylayoutForm").eq(index).find("#mylayout").combobox({
        onChange: function (newVal,oldVal) {
        	if (!isBlank(oldVal)) recreateLayout(index,newVal);
        }
    });
}

function addTreeGridLayoutForm(index){
	$(getTreeGridLayoutFormContent(index)).appendTo("#domainsdiv");
	$.parser.parse($("#domainsdiv"));
	$(".mylayoutForm").eq(index).find("#mylayout").combobox({
        onChange: function (newVal,oldVal) {
        	if (!isBlank(oldVal)) recreateLayout(index,newVal);
        }
    });
}

function addTreeParentChildLayoutForm(index){
	$(getTreeParentChildLayoutFormContent(index)).appendTo("#domainsdiv");
	$.parser.parse($("#domainsdiv"));
	$(".mylayoutForm").eq(index).find("#mylayout").combobox({
        onChange: function (newVal,oldVal) {
        	if (!isBlank(oldVal)) recreateLayout(index,newVal);
        }
    });
}

function addEchartsReportForm(index){
	$(getEchartsReportFormContent(index)).appendTo("#domainsdiv");
	$.parser.parse($("#domainsdiv"));
	$(".reportForm").eq(index).find("#report").combobox({
        onChange: function (newVal,oldVal) {
        	if (!isBlank(oldVal)) recreateReport(index,newVal);
        }
    });
}

function addEchartsGridReportForm(index){
	$(getEchartsGridReportFormContent(index)).appendTo("#domainsdiv");
	$.parser.parse($("#domainsdiv"));
	$(".reportForm").eq(index).find("#report").combobox({
        onChange: function (newVal,oldVal) {
        	if (!isBlank(oldVal)) recreateReport(index,newVal);
        }
    });
}

function addEchartsCompareGridReportForm(index){
	$(getEchartsCompareGridReportFormContent(index)).appendTo("#domainsdiv");
	$.parser.parse($("#domainsdiv"));
	$(".reportForm").eq(index).find("#report").combobox({
        onChange: function (newVal,oldVal) {
        	if (!isBlank(oldVal)) recreateReport(index,newVal);
        }
    });
}

function parseSampleTemplate(fileName){
	$("#generateResults").html("");
	var ignoreWarning = $("#ignoreWarning").prop("checked");
	var javaCompatibility = $("#javaCompatibility").prop("checked");
	var goCompatibility = $("#goCompatibility").prop("checked");
	$.ajax({
        type: "post",
        url: "../facade/parseSampleTemplateFacade",
        data: {fileName:fileName,ignoreWarning:ignoreWarning,javaCompatibility:javaCompatibility,goCompatibility:goCompatibility},
        dataType: 'json',
        success: function(data, textStatus) {
			debugger;
           if (data.success == true){
				$.messager.alert("信息", "示例解析成功，欢迎使用！");
           		listServerData();
           }else if (data.success == false){
        	   var resultStr ="";
        	   if (data.compileErrors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.compileErrors.length;i++){
	        		   resultStr += data.compileErrors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (data.compileWarnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt;width:800px'>";    	   		 
	        	   for (var i = 0; i < data.compileWarnings.length;i++){
	        		   resultStr += data.compileWarnings[i];
	        		   resultStr += "<br/>" 
	        	   }
	        	   resultStr += "</span>";
        	   }
    		   if (!!resultStr) $("#generateResults").html(resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function addDataDomain(){
	var serial = $('#datadomainfieldsform').find("#serial").val();
	//alert(serial);
	
	var fieldcatlog = [];
	if (!isBlank($("#datadomainfieldsform").find(".fieldcatlog"))) {
		$("#datadomainfieldsform").find(".fieldcatlog").each(
			function(){fieldcatlog.push($(this).val())})
	}
	var fieldname = [];
	if (!isBlank($("#datadomainfieldsform").find(".fieldname"))) {
		$("#datadomainfieldsform").find(".fieldname").each(
			function(){fieldname.push($(this).val())})
	}
	var fieldlabel = [];
	if (!isBlank($("#datadomainfieldsform").find(".fieldlabel"))) {
		$("#datadomainfieldsform").find(".fieldlabel").each(
			function(){fieldlabel.push($(this).val())})
	}
	var fieldvalue = [];
	if (!isBlank($("#datadomainfieldsform").find(".fieldvalue"))) {
		$("#datadomainfieldsform").find(".fieldvalue").each(
			function(){fieldvalue.push($(this).val())})
	}
	if (!validateId($("#datadomainfieldsform").find("#domainidvalue").val())){
		$.messager.alert("错误", "主键值不合法！");
		return;
	}
	for (var i=0;i<fieldcatlog.length;i++){
		if (fieldcatlog[i]=="dropdown"){
			if (!validateId(fieldvalue[i])){
				$.messager.alert("错误", "下拉列表值不合法！");	
				return;
			}
		}
	}

	$.ajax({
        type: "post",
        url: "../facade/addDataDomainWithSerialFacade",       
        data: {serial:serial,
        	domainid:$("#datadomainfieldsform").find("#domainid").val(),
        	domainidvalue:$("#datadomainfieldsform").find("#domainidvalue").val(),
        	domainiddeny:$("#datadomainfieldsform").find("#domainiddeny").prop("checked"),
        	domainname:$("#datadomainfieldsform").find("#domainname").val(),
        	domainnamevalue:$("#datadomainfieldsform").find("#domainnamevalue").val(),
        	domainnamedeny:$("#datadomainfieldsform").find("#domainnamedeny").prop("checked"),
        	activefield:$("#datadomainfieldsform").find("#activefield").val(),
        	activefielddeny:$("#datadomainfieldsform").find("#activefielddeny").prop("checked"),
        	activefieldvalue:$("#datadomainfieldsform").find("#activefieldvalue").val(),
        	fieldname:fieldname,
        	fieldvalue:fieldvalue
       	},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   	$('#waddDataDomain').window('close'); 
				$.messager.alert("信息", "新增域对象数据成功，欢迎使用！");			
           		listServerData();
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function deleteDataDomain(){
	var serial = $("#menuform").find("#serial").val();
	var index = $("#menuform").find("#index").val();
	$.ajax({
        type: "post",
        url: "../facade/deleteDataDomainWithSerialIndexFacade",
        data: {serial:serial,
			   index:index
       	},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
				$.messager.alert("信息", "删除域对象数据成功，欢迎使用！");			
				loadDataGrid(serial);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });
}


function wdeleteAllDataDomains(serial){
	$.messager.confirm("警告", "确定删除此域对象的全部数据？", function (data) {
	    if (data) {
	    	$.ajax({
	            type: "post",
	            url: "../facade/deleteAllDataDomainsWithSerialFacade",
	            data: {serial:serial},
	            dataType: 'json',
	            success: function(data, textStatus) {
	    					debugger;
	               if (data.success == true){
	    				$.messager.alert("信息", "删除域对象全部数据成功，欢迎使用！");			
	    				loadDataGrid(serial);
	               }
	            },
	            complete : function(XMLHttpRequest, textStatus) {
	            
	    		},
	    		error : function(XMLHttpRequest,textStatus,errorThrown) {
	    			//alert("Error:"+textStatus);
	    			//alert(errorThrown.toString());
	    		}
	        });
	     }
	});
	
}

function updateDataDomain(){
	var serial = $("#updatedatadomainform").find("#serial").val();
	var index = $("#updatedatadomainform").find("#index").val();

	var fieldcatlog = [];
	if (!isBlank($("#updatedatadomainform").find(".fieldcatlog"))) {
		$("#updatedatadomainform").find(".fieldcatlog").each(
			function(){fieldcatlog.push($(this).val())})
	}
	var fieldname = [];
	if (!isBlank($("#updatedatadomainform").find(".fieldname"))) {
		$("#updatedatadomainform").find(".fieldname").each(
			function(){fieldname.push($(this).val())})
	}
	var fieldlabel = [];
	if (!isBlank($("#updatedatadomainform").find(".fieldlabel"))) {
		$("#updatedatadomainform").find(".fieldlabel").each(
			function(){fieldlabel.push($(this).val())})
	}
	var fieldvalue = [];
	if (!isBlank($("#updatedatadomainform").find(".fieldvalue"))) {
		$("#updatedatadomainform").find(".fieldvalue").each(
			function(){fieldvalue.push($(this).val())})
	}
	
	if (!validateId($("#updatedatadomainform").find("#domainidvalue").val())){
		$.messager.alert("错误", "主键值不合法！");
		return;
	}
	for (var i=0;i<fieldcatlog.length;i++){
		if (fieldcatlog[i]=="dropdown"){
			if (!validateId(fieldvalue[i])){
				$.messager.alert("错误", "下拉列表值不合法！");	
				return;
			}
		}
	}
	
	$.ajax({
        type: "post",
        url: "../facade/updateDataDomainWithSerialIndexFacade",
        data: {serial:serial,
        	index:index,
        	domainid:$("#updatedatadomainform").find("#domainid").val(),
        	domainidvalue:$("#updatedatadomainform").find("#domainidvalue").val(),
        	domainiddeny:$("#updatedatadomainform").find("#domainiddeny").checkbox("options").checked,
        	domainname:$("#updatedatadomainform").find("#domainname").val(),
        	domainnamevalue:$("#updatedatadomainform").find("#domainnamevalue").val(),
        	domainnamedeny:$("#updatedatadomainform").find("#domainnamedeny").checkbox("options").checked,
        	activefield:$("#updatedatadomainform").find("#activefield").val(),
        	activefielddeny:$("#updatedatadomainform").find("#activefielddeny").checkbox("options").checked,
        	activefieldvalue:$("#updatedatadomainform").find("#activefieldvalue").val(),
        	fieldname:fieldname,
        	fieldvalue:fieldvalue
       	},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   	$('#wupdateDataDomain').window('close'); 
				$.messager.alert("信息", "新增域对象数据成功，欢迎使用！");			
				loadDataGrid(serial);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function winitUpdateDataDomain(serial){
	var index = $($("#domainsdiv").find(".dg").get(serial)).datagrid('getRowIndex',$($("#domainsdiv").find(".dg").get(serial)).datagrid('getSelected'));
	var dataLineStartIndex = 4
	if ($($("#domainsdiv").find(".dg").get(serial)).datagrid('getData').rows.length<5) dataLineStartIndex =4;
	else if ($($("#domainsdiv").find(".dg").get(serial)).datagrid('getData').rows[4]["字段"]== "固定名字") dataLineStartIndex=5;
	if (index >=dataLineStartIndex) index -= dataLineStartIndex;
	else return;
	$("#menuform").find("#serial").val(serial);
	$("#menuform").find("#index").val(index);
	initUpdateDataDomain();
}

function wdeleteDataDomain(serial){
	var index = $($("#domainsdiv").find(".dg").get(serial)).datagrid('getRowIndex',$($("#domainsdiv").find(".dg").get(serial)).datagrid('getSelected'));
	var dataLineStartIndex = 4
	if ($($("#domainsdiv").find(".dg").get(serial)).datagrid('getData').rows.length<5) dataLineStartIndex =4;
	else if ($($("#domainsdiv").find(".dg").get(serial)).datagrid('getData').rows[4]["字段"]== "固定名字") dataLineStartIndex=5;
	if (index >=dataLineStartIndex) index -= dataLineStartIndex;	
	else return;
	$("#menuform").find("#serial").val(serial);
	$("#menuform").find("#index").val(index);
	deleteDataDomain();
}

function  checkUseCust(){
	if ($("#useAdvancedCustomize").get(0).checked==true){
		$.messager.confirm("警告", "高级定制可能使代码生成物通不过编译，确定使用？", function (data) {
		    if (data) {
		    	$("#useAdvancedCustomize").get(0).checked=true;
		    	$("#useCust").css("display","block");
		     }else {
		    	 $("#useAdvancedCustomize").get(0).checked=false;
		    	 $("#useCust").css("display","none");
		     }
		});
	}else{
		$("#useCust").css("display","none");
	}
}

function  checkUseUserPartial(){
	if ($("#useUserPartial").get(0).checked==true){
		$.messager.confirm("警告", "部分生成功能可能使代码生成物通不过编译，确定使用？", function (data) {
		    if (data) {
		    	listProjectPartials();
		    	$("#useUserPartial").get(0).checked=true;
		    	$("#usePartial").css("display","block");
		     }else {
		    	 $("#useUserPartial").get(0).checked=false;
		    	 $("#usePartial").css("display","none");
		     }
		});
	}else{
		$("#usePartial").css("display","none");
	}
}

function wizardGenerateSource(){	
	if (!validateServerProject()) return;
	$("#generateResults").html("");
	updateProjectAndAllDomains();
	$.ajax({
        type: "post",
        async:false,
        url: "../facade/generateFromExcelWizardFacade",
        data: {ignoreWarning:$("#ignoreWarning").prop("checked"),
    		genFormatted:false,
    		generateFront:$("#generateFront").prop("checked"),
    		frontUseProjectName:$("#frontUseProjectName").prop("checked"),
    		frontUseControllerPrefix:$("#frontUseControllerPrefix").prop("checked"),
    		sqlComments:$("#sqlComments").prop("checked"),
    		javaCompatibility:$("#javaCompatibility").prop("checked"),
    		goCompatibility:$("#goCompatibility").prop("checked"),
    		
    		useAdvancedCustomize:$("#useAdvancedCustomize").prop("checked"),
    		genUi:$("#genUi").prop("checked"),
    		genController:$("#genController").prop("checked"),
    		genService:true,
    		genServiceImpl:$("#genServiceImpl").prop("checked"),
    		genDao:true,
    		genDaoImpl:$("#genDaoImpl").prop("checked"),
    		
    		useUserPartial:$("#useUserPartial").prop("checked"),
    		exportStr:buildExportStr()
       	},
        dataType: 'json',
        async:false,
        success: function(data, textStatus) {
			//debugger;
	           if (data.success == true){	        	   
           			var content = "<strong>"+data.projectName+"</strong><a href=\"../source/"+data.projectName+".zip\">点击下载后端项目</a><br>";
           			if (!isBlank(data.frontProjectName)) content +=	"<strong>"+data.frontProjectName+"</strong><a href=\"../source/"+data.frontProjectName+".zip\">点击下载前端项目</a><br>";
    				$("#generateResults").html(content);
    				$.messager.alert("信息", "直接代码生成成功，欢迎下载使用！");
	           }else if (data.success == false){
	        	   var resultStr ="";
	        	   if (!isBlank(data.compileErrors) && data.compileErrors.length > 0) {
		        	   resultStr = "<span style='color:red;font-size:16pt''>";
		        	   for (var i = 0; i < data.compileErrors.length;i++){
		        		   resultStr += data.compileErrors[i];
		        		   resultStr += "<br/>"
	        	 		   }   
		        	   resultStr += "</span>";
		           }
	        	   if (!isBlank(data.compileWarnings) && data.compileWarnings.length > 0){
		        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
		        	   for (var i = 0; i < data.compileWarnings.length;i++){
		        		   resultStr += data.compileWarnings[i];
		        		   resultStr += "<br/>" 
		        	   }
		        	   resultStr += "</span>";
	        	   }
        		   if (!!resultStr) $("#generateResults").html(resultStr);
	           }
	        }
	});
}

function deleteDomain(serial){
	$.messager.confirm("警告", "即将删除相应的域对象和域对象的数据，确定使用？", function (data) {
	    if (data) {
	    	$.ajax({
	            type: "post",
	            url: "../facade/deleteDomainWithSerialFacade",
	            data: {serial:serial,
	           	},
	            dataType: 'json',
	            success: function(data, textStatus) {
	    					debugger;
	               if (data.success == true){
	    				$.messager.alert("信息", "删除域对象及其数据成功，欢迎使用！");			
	    				listServerData();
	               }
	            },
	            complete : function(XMLHttpRequest, textStatus) {
	            
	    		},
	    		error : function(XMLHttpRequest,textStatus,errorThrown) {
	    			//alert("Error:"+textStatus);
	    			//alert(errorThrown.toString());
	    		}
	        });	
	     }
	});	
}


function switchToEnum(serial){
   	$.ajax({
           type: "post",
           url: "../facade/switchToEnumWithSerialFacade",
           data: {serial:serial,
          	},
           dataType: 'json',
           success: function(data, textStatus) {
   					debugger;
              if (data.success == true){
   				$.messager.alert("信息", "切换域对象至枚举成功，欢迎使用！");			
   				listServerData();
              }
           },
           complete : function(XMLHttpRequest, textStatus) {
           
   		},
   		error : function(XMLHttpRequest,textStatus,errorThrown) {
   			//alert("Error:"+textStatus);
   			//alert(errorThrown.toString());
   		}
       });	
}

function switchToDomain(serial){
   	$.ajax({
           type: "post",
           url: "../facade/switchToDomainWithSerialFacade",
           data: {serial:serial,
          	},
           dataType: 'json',
           success: function(data, textStatus) {
   					debugger;
              if (data.success == true){
   				$.messager.alert("信息", "切换枚举至域对象成功，欢迎使用！");			
   				listServerData();
              }
           },
           complete : function(XMLHttpRequest, textStatus) {
           
   		},
   		error : function(XMLHttpRequest,textStatus,errorThrown) {
   			//alert("Error:"+textStatus);
   			//alert(errorThrown.toString());
   		}
       });	
}


function updateProjectAndAllDomainsWithComplex(){
	updateProject(true);
	$('#projectform').each(function(){ $(this).find('input').validatebox({ novalidate:true })}); 
	var domainCount = $(".domainpanel").length;
	var success = false;
	for (var i=0;i<domainCount;i++){
		updateDomain(i,true);
		if (!validateDomain(i)) {
			$.messager.alert("错误", "域对象"+(i+1)+"未完整设置！");
			return false;
		}
	}
	return true;
}

function pureUpdateProjectAndAllDomains(){
	updateProject(true);
	var domainCount = $(".domainpanel").length;
	for (var i=0;i<domainCount;i++){
		updateDomain(i,true);
	}	
}

function countDomains(){
	updateProject(true);
	var domainCount = $(".domainpanel").length;
	return domainCount;
}

function updateProjectAndAllDomains(){
	updateProject(true);
	var domainCount = $(".domainpanel").length;
	for (var i=0;i<domainCount;i++){
		updateDomain(i,true);
	}	
	var moduleCount = $(".modulepanel").length;
	for (var i=0;i<moduleCount;i++){
		updateSimpleAuthModule(true);
	}
	var mtmcCount = $(".mtmcandidatepanel").length;
	for (var i=0;i<mtmcCount;i++){
		pureUpdateMtmCandidate(i);
	}
	var mylayoutCount = $(".mylayoutpanel").length;
	for (var i=0;i<mylayoutCount;i++){
		if ($(".mylayoutForm").eq(i).find("#mylayout").combobox("getValue")=="ParentChild") updateParentChildLayout(i,true);
		if ($(".mylayoutForm").eq(i).find("#mylayout").combobox("getValue")=="TreeGrid") updateTreeGridLayout(i,true);
		if ($(".mylayoutForm").eq(i).find("#mylayout").combobox("getValue")=="TreeParentChild") updateTreeParentChildLayout(i,true);
	}
	var reportCount = $(".reportpanel").length;
	for (var i=0;i<reportCount;i++){
		if ($(".reportForm").eq(i).find("#report").combobox("getValue")=="EchartsReport") updateEchartsReport(i,true);
		if ($(".reportForm").eq(i).find("#report").combobox("getValue")=="EchartsGridReport") updateEchartsGridReport(i,true);
		if ($(".reportForm").eq(i).find("#report").combobox("getValue")=="EchartsCompareGridReport") updateEchartsCompareGridReport(i,true);
	}
}

function validateId(val){
	if (isBlank(val)) return true;
	var reg = /^([0]|[1-9][0-9]*)$/
	return reg.test(val);
}

if ($.fn.pagination){
	$.fn.pagination.defaults.beforePageText = '第';
	$.fn.pagination.defaults.afterPageText = '共{pages}页';
	$.fn.pagination.defaults.displayMsg = '显示{from}到{to},共{total}记录';
}
if ($.fn.datagrid){
	$.fn.datagrid.defaults.loadMsg = '正在处理，请稍待。。。';
}
if ($.fn.treegrid && $.fn.datagrid){
	$.fn.treegrid.defaults.loadMsg = $.fn.datagrid.defaults.loadMsg;
}
if ($.messager){
	$.messager.defaults.ok = '确定';
	$.messager.defaults.cancel = '取消';
}
$.map(['validatebox','textbox','filebox','searchbox',
		'combo','combobox','combogrid','combotree',
		'datebox','datetimebox','numberbox',
		'spinner','numberspinner','timespinner','datetimespinner'], function(plugin){
	if ($.fn[plugin]){
		$.fn[plugin].defaults.missingMessage = '该输入项为必输项';
	}
});
if ($.fn.validatebox){
	$.fn.validatebox.defaults.rules.email.message = '请输入有效的电子邮件地址';
	$.fn.validatebox.defaults.rules.url.message = '请输入有效的URL地址';
	$.fn.validatebox.defaults.rules.length.message = '输入内容长度必须介于{0}和{1}之间';
	$.fn.validatebox.defaults.rules.remote.message = '请修正该字段';
}
if ($.fn.calendar){
	$.fn.calendar.defaults.weeks = ['日','一','二','三','四','五','六'];
	$.fn.calendar.defaults.months = ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'];
}
if ($.fn.datebox){
	$.fn.datebox.defaults.currentText = '今天';
	$.fn.datebox.defaults.closeText = '关闭';
	$.fn.datebox.defaults.okText = '确定';
	$.fn.datebox.defaults.formatter = function(date){
		var y = date.getFullYear();
		var m = date.getMonth()+1;
		var d = date.getDate();
		return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
	};
	$.fn.datebox.defaults.parser = function(s){
		if (!s) return new Date();
		var ss = s.split('-');
		var y = parseInt(ss[0],10);
		var m = parseInt(ss[1],10);
		var d = parseInt(ss[2],10);
		if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
			return new Date(y,m-1,d);
		} else {
			return new Date();
		}
	};
}
if ($.fn.datetimebox && $.fn.datebox){
	$.extend($.fn.datetimebox.defaults,{
		currentText: $.fn.datebox.defaults.currentText,
		closeText: $.fn.datebox.defaults.closeText,
		okText: $.fn.datebox.defaults.okText
	});
}
if ($.fn.datetimespinner){
	$.fn.datetimespinner.defaults.selections = [[0,4],[5,7],[8,10],[11,13],[14,16],[17,19]]
}

function createNewModule(){
	if (countDomains()<=0) {
		 $.messager.alert("错误", "请先设置域对象！");
		 return;
	}
	if (!updateProjectAndAllDomainsWithComplex()) return;
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"createNewModule"
       		},	
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   listServerData();
        	   $.messager.alert("信息", "SimpleAuth弹性模块新建成功，欢迎使用！");        	   
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function updateSimpleAuthModule(ignoreAlert){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"updateSimpleAuthModule",
        	    userdomain: $("#moduleForm").find("#userdomain").textbox("getValue"),
        	    roledomain:$("#moduleForm").find("#roledomain").textbox("getValue"),
        	    privilegedomain:$("#moduleForm").find("#privilegedomain").textbox("getValue")
       		},	
        dataType: 'json',
        async:false,
        success: function(data, textStatus) {
			debugger;
           if (ignoreAlert == false && data.success == true){
        	   listServerData();
        	   $.messager.alert("信息", "SimpleAuth弹性模块更新成功，欢迎使用！");        	   
           }else if (ignoreAlert == false && data.success == false){
        	   var resultStr ="";
        	   if (data.errors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.errors.length;i++){
	        		   resultStr += data.errors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (data.warnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.warnings.length;i++){
	        		   resultStr += data.warnings[i];
	        		   resultStr += "<br/>"
    	 		    }
        	   		resultStr += "</span>";
        	   }
        	   $.messager.alert("错误", resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function updateParentChildLayout(index,ignoreAlert){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"updateParentChildLayout",
        		index:index,
        	    parentdomain: $(".mylayoutForm").eq(index).find("#parentdomain").textbox("getValue"),
        	    childdomain:$(".mylayoutForm").eq(index).find("#childdomain").textbox("getValue"),
        	    parentidfield:$(".mylayoutForm").eq(index).find("#parentidfield").textbox("getValue")
       		},	
        dataType: 'json',
        async:false,
        success: function(data, textStatus) {
					debugger;
           if (ignoreAlert == false && data.success == true){
        	   listServerData();  	   
           }else if (ignoreAlert == false && data.success == false){
        	   var resultStr ="";
        	   if (data.errors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.errors.length;i++){
	        		   resultStr += data.errors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (data.warnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.warnings.length;i++){
	        		   resultStr += data.warnings[i];
	        		   resultStr += "<br/>"
    	 		    }
        	   		resultStr += "</span>";
        	   }
        	   $.messager.alert("错误", resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function updateTreeGridLayout(index,ignoreAlert){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"updateTreeGridLayout",
        		index:index,
        	    treedomain: $(".mylayoutForm").eq(index).find("#treedomain").textbox("getValue"),
        	    childdomain:$(".mylayoutForm").eq(index).find("#childdomain").textbox("getValue"),
        	    innertreeparentidfield:$(".mylayoutForm").eq(index).find("#innertreeparentidfield").textbox("getValue"),
        	    parentidfield:$(".mylayoutForm").eq(index).find("#parentidfield").textbox("getValue")
       		},	
        dataType: 'json',
        async:false,
        success: function(data, textStatus) {
			debugger;
           if (ignoreAlert == false && data.success == true){
        	   listServerData();  	   
           }else if (ignoreAlert == false && data.success == false){
        	   var resultStr ="";
        	   if (data.errors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.errors.length;i++){
	        		   resultStr += data.errors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (data.warnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.warnings.length;i++){
	        		   resultStr += data.warnings[i];
	        		   resultStr += "<br/>"
    	 		    }
        	   		resultStr += "</span>";
        	   }
        	   $.messager.alert("错误", resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function updateTreeParentChildLayout(index,ignoreAlert){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"updateTreeParentChildLayout",
        		index:index,
        	    treedomain: $(".mylayoutForm").eq(index).find("#treedomain").textbox("getValue"),
        	   	parentdomain: $(".mylayoutForm").eq(index).find("#parentdomain").textbox("getValue"),
        	    childdomain:$(".mylayoutForm").eq(index).find("#childdomain").textbox("getValue"),
        	    innertreeparentidfield:$(".mylayoutForm").eq(index).find("#innertreeparentidfield").textbox("getValue"),
        	    treeparentidfield:$(".mylayoutForm").eq(index).find("#treeparentidfield").textbox("getValue"),
        	    parentidfield:$(".mylayoutForm").eq(index).find("#parentidfield").textbox("getValue")
       		},	
        dataType: 'json',
        async:false,
        success: function(data, textStatus) {
			debugger;
           if (ignoreAlert == false && data.success == true){
        	   listServerData();  	   
           }else if (ignoreAlert == false && data.success == false){
        	   var resultStr ="";
        	   if (data.errors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.errors.length;i++){
	        		   resultStr += data.errors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (data.warnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.warnings.length;i++){
	        		   resultStr += data.warnings[i];
	        		   resultStr += "<br/>"
    	 		    }
        	   		resultStr += "</span>";
        	   }
        	   $.messager.alert("错误", resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function updateEchartsReport(index,ignoreAlert){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"updateEchartsReport",
        		index:index,
        		reportdomain: $(".reportForm").eq(index).find("#reportdomain").textbox("getValue"),
        	    xaxisfields:$(".reportForm").eq(index).find("#xaxisfields").textbox("getValue"),
        	    yname:$(".reportForm").eq(index).find("#yname").textbox("getValue")
       		},	
        dataType: 'json',
        async:false,
        success: function(data, textStatus) {
			debugger;
			if (ignoreAlert == false && data.success == true){
				listServerData();  	   
			}else if (ignoreAlert == false && data.success == false){
        	   var resultStr ="";
        	   if (data.errors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.errors.length;i++){
	        		   resultStr += data.errors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (data.warnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.warnings.length;i++){
	        		   resultStr += data.warnings[i];
	        		   resultStr += "<br/>"
    	 		    }
        	   		resultStr += "</span>";
        	   }
        	   $.messager.alert("错误", resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function updateEchartsGridReport(index,ignoreAlert){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"updateEchartsGridReport",
        		index:index,
        		reportdomain: $(".reportForm").eq(index).find("#reportdomain").textbox("getValue"),
        	    xaxisfields:$(".reportForm").eq(index).find("#xaxisfields").textbox("getValue"),
        	    yname:$(".reportForm").eq(index).find("#yname").textbox("getValue")
       		},	
        dataType: 'json',
        async:false,
        success: function(data, textStatus) {
			debugger;
           if (ignoreAlert == false && data.success == true){
        	   listServerData();  	   
           }else if (ignoreAlert == false && data.success == false){
        	   var resultStr ="";
        	   if (data.errors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.errors.length;i++){
	        		   resultStr += data.errors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (data.warnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.warnings.length;i++){
	        		   resultStr += data.warnings[i];
	        		   resultStr += "<br/>"
    	 		    }
        	   		resultStr += "</span>";
        	   }
        	   $.messager.alert("错误", resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function updateEchartsCompareGridReport(index,ignoreAlert){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"updateEchartsCompareGridReport",
        		index:index,
        		plandomain: $(".reportForm").eq(index).find("#plandomain").textbox("getValue"),
        	    planxaxisfields:$(".reportForm").eq(index).find("#planxaxisfields").textbox("getValue"),
        	    planyname:$(".reportForm").eq(index).find("#planyname").textbox("getValue"),
        	    
        	    actiondomain: $(".reportForm").eq(index).find("#actiondomain").textbox("getValue"),
        	    actionxaxisfields:$(".reportForm").eq(index).find("#actionxaxisfields").textbox("getValue"),
        	    actionyname:$(".reportForm").eq(index).find("#actionyname").textbox("getValue")
       		},	
        dataType: 'json',
        async:false,
        success: function(data, textStatus) {
			debugger;
			if (ignoreAlert == false && data.success == true){
				listServerData();  	   
           }else if (ignoreAlert == false && data.success == false){
        	   var resultStr ="";
        	   if (data.errors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.errors.length;i++){
	        		   resultStr += data.errors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (data.warnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.warnings.length;i++){
	        		   resultStr += data.warnings[i];
	        		   resultStr += "<br/>"
    	 		    }
        	   		resultStr += "</span>";
        	   }
        	   $.messager.alert("错误", resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function deleteSimpleAuthModule(){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"deleteSimpleAuthModule"
       		},	
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   listServerData();
        	   $.messager.alert("信息", "SimpleAuth弹性模块删除成功，欢迎使用！");        	  
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function createParentChildLayout(){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"createParentChildLayout"
       		},	
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   listServerData();
        	   $.messager.alert("信息", "ParentChild版面新建成功，欢迎使用！");        	   
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function recreateLayout(index,commandStr){
	$("#generateResults").html("");
	var command = "recreateParentChildLayout";
	if (commandStr == "ParentChild"){
		command = "recreateParentChildLayout";
	}else if (commandStr == "TreeGrid"){
		command = "recreateTreeGridLayout";
	}else if (commandStr == "TreeParentChild"){
		command = "recreateTreeParentChildLayout";
	}
	
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:command,
        		index:index
       		},	
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   listServerData();
			}
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function recreateReport(index,commandStr){
	if (!updateProjectAndAllDomainsWithComplex()) return;
	$("#generateResults").html("");
	var command = "recreateEchartsReport";
	if (commandStr == "EchartsReport"){
		command = "recreateEchartsReport";
	}else if (commandStr == "EchartsGridReport"){
		command = "recreateEchartsGridReport";
	}else if (commandStr == "EchartsCompareGridReport"){
		command = "recreateEchartsCompareGridReport";
	}
	
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:command,
        		index:index
       		},	
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   listServerData();
			}
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function deleteLayout(index){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"deleteLayout",
        	   index:index
       		},	
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   listServerData();
        	   $.messager.alert("信息", "复杂版面删除成功，欢迎使用！");        	  
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function createEchartsReport(){
	if (countDomains()<=0) {
		 $.messager.alert("错误", "请先设置域对象！");
		 return;
	}
	if (!updateProjectAndAllDomainsWithComplex()) return;
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"createEchartsReport"
       		},	
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   listServerData();
        	   $.messager.alert("信息", "EchartsReport报表新建成功，欢迎使用！");        	   
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function deleteReport(index){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"deleteReport",
        	   index:index
       		},	
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   listServerData();
        	   $.messager.alert("信息", "报表删除成功，欢迎使用！");        	  
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function listServerData() {
	$("#domainsdiv").html("");
	$.parser.parse($("#domainsdiv"));
	$.parser.parse($("#projectform"));
	$.ajax({
        url: '../facade/listServerProjectDomainsDataFacade',
        type: 'POST',
        async: false,
        dataType: 'json',
       	success: function (data, textStatus) {
           if (data != null && data.success ==true) {
				$("#projectform").find("#fileName").textbox("setValue",data.fileName);
				$("#projectform").find("#project").textbox("setValue",data.project);
				$("#projectform").find("#packagetoken").textbox("setValue",data.packagetoken);
				$("#projectform").find("#dbprefix").textbox("setValue",data.dbprefix);
				$("#projectform").find("#dbname").textbox("setValue",data.dbname);
				$("#projectform").find("#dbusername").textbox("setValue",data.dbusername);
				$("#projectform").find("#dbpassword").textbox("setValue",data.dbpassword);
				var dbtype = "mariadb";
				if (!isBlank(data.dbtype)) dbtype= data.dbtype.toLowerCase();
				if (dbtype=="pgsql") dbtype ="postgresql";
				$("#projectform").find("#dbtype").combobox("select",dbtype);
				var technicalstack = "mjeeeu";
				if (!isBlank(data.technicalstack)) technicalstack= data.technicalstack.toLowerCase();
				$("#projectform").find("#technicalstack").combobox("select",technicalstack);
				$("#projectform").find("#title").textbox("setValue",data.title);
				$("#projectform").find("#subtitle").textbox("setValue",data.subtitle);
				$("#projectform").find("#footer").textbox("setValue",data.footer);
				$("#projectform").find("#crossorigin").textbox("setValue",data.crossorigin);
				var resolution = "high"; 
				if (!isBlank(data.resolution)) resolution= data.resolution.toLowerCase();
				$("#projectform").find("#resolution").combobox("select",resolution);
				$("#projectform").find("#domainsuffix").textbox("setValue",data.domainsuffix);
				$("#projectform").find("#daosuffix").textbox("setValue",data.daosuffix);
				$("#projectform").find("#daoimplsuffix").textbox("setValue",data.daoimplsuffix);
				$("#projectform").find("#servicesuffix").textbox("setValue",data.servicesuffix);
				$("#projectform").find("#serviceimplsuffix").textbox("setValue",data.serviceimplsuffix);
				$("#projectform").find("#controllersuffix").textbox("setValue",data.controllersuffix);
				$("#projectform").find("#domainnamingsuffix").textbox("setValue",data.domainnamingsuffix);
				$("#projectform").find("#controllernamingsuffix").textbox("setValue",data.controllernamingsuffix);
				var language = "chinese"; 
				if (!isBlank(data.language)) language=data.language.toLowerCase();
				$("#projectform").find("#language").combobox("select",language);
				var schema = "normal"; 
				if (!isBlank(data.schema)) schema= data.schema.toLowerCase();
				$("#projectform").find("#schema").combobox("select",schema);
				var frontbaseapi = "";
				if (!isBlank(data.frontbaseapi)) frontbaseapi= data.frontbaseapi;
				$("#projectform").find("#frontbaseapi").textbox("setValue",frontbaseapi);
				var frontendUi = "vueElNode21";
				if (!isBlank(data.frontendUi)) frontendUi= data.frontendUi;
				$("#projectform").find("#frontendUi").combobox("setValue",frontendUi);
				var backendUi = "easyUi";
				if (!isBlank(data.backendUi)) backendUi= data.backendUi;
				$("#projectform").find("#backendUi").combobox("setValue",backendUi);
				var computerlanguage = "";
				if (!isBlank(data.computerlanguage)) computerlanguage= data.computerlanguage;
				$("#projectform").find("#computerlanguage").textbox("setValue",computerlanguage);

				if (data.domains!=null && data.domains.length>0){
					var count = data.domains.length;
					addDomainForms(data.domains);					
					for (var i=0;i<count;i++){
						$($("#domainsdiv").find(".domainForm").get(i)).find("#domain").textbox("setValue",data.domains[i].domainName);
						$($("#domainsdiv").find(".domainForm").get(i)).find("#plural").textbox("setValue",data.domains[i].plural);
						$($("#domainsdiv").find(".domainForm").get(i)).find("#tableprefix").textbox("setValue",data.domains[i].tableprefix);
						$($("#domainsdiv").find(".domainForm").get(i)).find("#domainlabel").textbox("setValue",data.domains[i].domainlabel);
						$($("#domainsdiv").find(".domainForm").get(i)).find("#verbdenies").textbox("setValue",data.domains[i].verbdenies);
						loadDataGrid(i);
					}
				}
				
				if (data.mtmCandidates!=null && data.mtmCandidates.length>0){
					var count = data.mtmCandidates.length;
					addMtmCandidates(count);
					for (var i=0;i<count;i++){
						var domaindata = listProjectDomainNames();
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#masterName").combobox("loadData",domaindata); 
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#slaveName").combobox("loadData", domaindata);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#masterName").combobox("setValue", data.mtmCandidates[i].masterName);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#slaveName").combobox("setValue", data.mtmCandidates[i].slaveName);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#slaveAlias").textbox("setValue", data.mtmCandidates[i].slaveAlias);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#label").textbox("setValue", data.mtmCandidates[i].label);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#masterId").textbox("setValue", data.mtmCandidates[i].masterId);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#slaveId").textbox("setValue", data.mtmCandidates[i].slaveId);
					}
				}
				
				if (data.modules!=null && data.modules.length>0){
					addSimpleAuthModuleForm();
					$("#domainsdiv").find(".moduleForm").find("#module").textbox("setValue",data.modules[0].module);
					$("#domainsdiv").find(".moduleForm").find("#userdomain").textbox("setValue",data.modules[0].userdomain);		
					$("#domainsdiv").find(".moduleForm").find("#roledomain").textbox("setValue",data.modules[0].roledomain);	
					$("#domainsdiv").find(".moduleForm").find("#privilegedomain").textbox("setValue",data.modules[0].privilegedomain);
				}
				if (data.mylayouts!=null && data.mylayouts.length>0){
					var mylayouts = data.mylayouts;
					var count = data.mylayouts.length;
					for (var i=0;i<count;i++){
						if (data.mylayouts[i].mylayout=="ParentChild") {
							addParentChildLayoutForm(i);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#mylayout").combobox("select",data.mylayouts[i].mylayout);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#parentdomain").textbox("setValue",data.mylayouts[i].parentdomain);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#childdomain").textbox("setValue",data.mylayouts[i].childdomain);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#parentidfield").textbox("setValue",data.mylayouts[i].parentidfield);
						}
						if (data.mylayouts[i].mylayout=="TreeGrid") {
							addTreeGridLayoutForm(i);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#mylayout").combobox("select",data.mylayouts[i].mylayout);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#treedomain").textbox("setValue",data.mylayouts[i].treedomain);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#childdomain").textbox("setValue",data.mylayouts[i].childdomain);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#innertreeparentidfield").textbox("setValue",data.mylayouts[i].innertreeparentidfield);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#parentidfield").textbox("setValue",data.mylayouts[i].parentidfield);
						}
						if (data.mylayouts[i].mylayout=="TreeParentChild") {
							addTreeParentChildLayoutForm(i);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#mylayout").combobox("select",data.mylayouts[i].mylayout);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#treedomain").textbox("setValue",data.mylayouts[i].treedomain);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#parentdomain").textbox("setValue",data.mylayouts[i].parentdomain);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#childdomain").textbox("setValue",data.mylayouts[i].childdomain);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#innertreeparentidfield").textbox("setValue",data.mylayouts[i].innertreeparentidfield);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#treeparentidfield").textbox("setValue",data.mylayouts[i].treeparentidfield);
							$("#domainsdiv").find(".mylayoutForm").eq(i).find("#parentidfield").textbox("setValue",data.mylayouts[i].parentidfield);
						}
					}
				}
				if (data.reports!=null && data.reports.length>0){
					var count = data.reports.length;
					for (var i=0;i<count;i++){
						if (data.reports[i].report=="EchartsReport") addEchartsReportForm(i);
						if (data.reports[i].report=="EchartsGridReport") addEchartsGridReportForm(i);
						if (data.reports[i].report=="EchartsCompareGridReport") addEchartsCompareGridReportForm(i);
					}
					for (var i=0;i<count;i++){
						if (data.reports[i].report=="EchartsReport"){
							$($("#domainsdiv").find(".reportForm").get(i)).find("#report").combobox("select",data.reports[i].report);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#reportdomain").textbox("setValue",data.reports[i].reportdomain);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#xaxisfields").textbox("setValue",data.reports[i].xaxisfields);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#yname").textbox("setValue",data.reports[i].yname);
						}
						if (data.reports[i].report=="EchartsGridReport"){
							$($("#domainsdiv").find(".reportForm").get(i)).find("#report").combobox("select",data.reports[i].report);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#reportdomain").textbox("setValue",data.reports[i].reportdomain);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#xaxisfields").textbox("setValue",data.reports[i].xaxisfields);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#yname").textbox("setValue",data.reports[i].yname);
						}
						if (data.reports[i].report=="EchartsCompareGridReport"){
							$($("#domainsdiv").find(".reportForm").get(i)).find("#report").combobox("select",data.reports[i].report);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#plandomain").textbox("setValue",data.reports[i].plandomain);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#planxaxisfields").textbox("setValue",data.reports[i].planxaxisfields);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#planyname").textbox("setValue",data.reports[i].planyname);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#actiondomain").textbox("setValue",data.reports[i].actiondomain);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#actionxaxisfields").textbox("setValue",data.reports[i].actionxaxisfields);
							$($("#domainsdiv").find(".reportForm").get(i)).find("#actionyname").textbox("setValue",data.reports[i].actionyname);
						}
					}
				}
				if (data.mtmCandidates!=null && data.mtmCandidates.length>0){
					var count = data.mtmCandidates.length;
					for (var i=0;i<count;i++){
						var mtmcValues = data.mtmCandidatesValues[i];
						if (mtmcValues != null && mtmcValues != undefined && mtmcValues.length > 0) $($("#domainsdiv").find(".mtmCandidateDg").get(i)).datagrid("loadData",mtmcValues);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#masterName").combobox("setValue", data.mtmCandidates[i].masterName);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#slaveName").combobox("setValue", data.mtmCandidates[i].slaveName);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#slaveAlias").textbox("setValue", data.mtmCandidates[i].slaveAlias);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#label").textbox("setValue", data.mtmCandidates[i].label);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#masterId").textbox("setValue", data.mtmCandidates[i].masterId);
						$($("#domainsdiv").find(".mtmCandidateForm").get(i)).find("#slaveAliasId").textbox("setValue", data.mtmCandidates[i].slaveAliasId);
					}
				}
           } else if (data.success == false){
        	   $.messager.alert("信息", data.reason);  
           }
       }
   });
}


function listProjectPartials() {
	$.ajax({
        url: '../facade/listServerProjectDomainsDataFacade',
        type: 'POST',
        async: false,
        dataType: 'json',
       	success: function (data, textStatus) {
           if (data != null && data.success ==true) {
        	    var result = "<table>";
        	    var count = 0;
        	    var i = 0;
				if (data.domains!=null && data.domains.length>0){
					count = data.domains.length;
					for (i=0;i<count;i++){
						result += generatePartialNames(i,data.domains[i].domainName);
					}
				}
				if (data.modules!=null && data.modules.length>0){
					count += 1;					
					result += generatePartialNames(i,data.modules[0].module);
					i += 1;
				}
				if (data.mylayouts!=null && data.mylayouts.length>0){
					count += data.mylayouts.length;
					for (var ii=0 ;ii<data.mylayouts.length;ii++){
						result += generatePartialNames(i,data.mylayouts[ii].standardName);
						i++;
					}
				}
				if (data.reports!=null && data.reports.length>0){
					count += data.reports.length;
					for (var ii=0 ;ii<data.reports.length;ii++){
						result += generatePartialNames(i,data.reports[ii].standardName);
						i++;
					}
				}
				result += "</tr></table>"
				$("#usePartial").html(result);
				$.parser.parse($("#usePartial"));
           }
       }
   });
}

function generatePartialNames(pos, name){
	var result = "";
	if (pos%3 == 0) result += "<tr>";
	result += '<td><input type="checkbox" class="mycheck" id="'+name+'" name="'+name+'" value="'+name+'">'+name+'</td>';
	if (pos%3 == 2) result += "</tr>";
	return result;
}

function buildExportStr(){
	var result = "";
	var checks = $("#usePartialForm").find(".mycheck:checked");
	for (var i=0;i<checks.length;i++){
		result = result + "" + checks.get(i).value +",";
	}
	if (result.includes("," )) result = result.substring(0,result.length -1);
	return result;
}

function autoReflectDb(){
	var dbSettings = lookupDbSettings();
	$("#ffdbedit").find("#dbType").combobox("setValue",dbSettings["dbType"]);
	$("#ffdbedit").find("#dbLink").textbox("setValue",dbSettings["dbLink"]);
	$("#ffdbedit").find("#dbHost").textbox("setValue",dbSettings["dbHost"]);
	$("#ffdbedit").find("#dbPort").textbox("setValue",dbSettings["dbPort"]);
	if (!isBlank(dbSettings["dbName"])) $("#ffdbedit").find("#databaseName").combobox("setValue",dbSettings["dbName"]);
	$("#ffdbedit").find("#userName").textbox("setValue",dbSettings["userName"]);
	$("#ffdbedit").find("#password").textbox("setValue",dbSettings["password"]);
	$("#ffdbedit").find("#topn").combobox("setValue",dbSettings["topn"]);
	$('#wupdateDb').window('open');
}


function lookupDbSettings(){
	var settings = {};
	$.ajax({
		type: "post",
		url: "../facade/lookupDbSettingsFacade",
		dataType: 'json',
		async:false,
		success: function(data, textStatus) {
			if (data.success){
				settings = data.rows;
			}
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
	return settings;
}

function updateDbSettings(){
	$.ajax({
		type: "post",
		url: "../facade/updateDbSettingsFacade",
		dataType: 'json',
		data: {
			dbType: $('#ffdbedit').find("#dbType").combobox("getValue"),
			dbHost: $('#ffdbedit').find("#dbHost").val(),
			dbPort: $('#ffdbedit').find("#dbPort").val(),
			dbName: $('#ffdbedit').find("#databaseName").combobox("getValue"),
			userName: $('#ffdbedit').find("#userName").val(),
			password: $('#ffdbedit').find("#password").val(),
			topn: $('#ffdbedit').find("#topn").val()
		},
		success: function(data, textStatus) {
			if (data.success){
				//$('#ffdbedit').find("#databaseName").combobox("clear");
				$('#ffdbedit').find("#databaseName").combobox("reload");
			}
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function reflectDbToProject(){
	$.ajax({
		type: "post",
		url: "../facade/reflectDbToProjectFacade",
		dataType: 'json',
		data: {
			dbType: $('#ffdbedit').find("#dbType").combobox("getValue"),
			dbHost: $('#ffdbedit').find("#dbHost").val(),
			dbPort: $('#ffdbedit').find("#dbPort").val(),
			dbName: $('#ffdbedit').find("#databaseName").combobox("getValue"),
			userName: $('#ffdbedit').find("#userName").val(),
			password: $('#ffdbedit').find("#password").val(),
			topn: $('#ffdbedit').find("#topn").val(),
			technicalStack:"jeeeu"
		},
		success: function(data, textStatus) {
			if (data.success){
				$('#wupdateDb').window('close');
				listServerData();
				$.messager.alert("信息", "数据库反射项目成功，欢迎使用！");
			}
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			alert(errorThrown.toString());
		}
	});
}

function clearLoginData(){
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/excelWizardFacade",
        data: {command:"clearLoginDataSimpleAuthModule"
       		},	
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
        	   listServerData();
        	   $.messager.alert("信息", "SimpleAuth弹性模块登录数据清洗成功，欢迎使用！");        	  
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function setupMtmCandidateMaster(record,index){
	var masterName = record.value;
	masterName = masterName.substring(0,1).toLowerCase()+masterName.substring(1,masterName.length)+"Id";
	$($(".mtmCandidateForm").get(index)).find("#masterId").textbox("setValue",masterName);
}

function changeSlaveAliasId(value, index){
	var slaveAliasId = value;
	if (slaveAliasId.endsWith("Id")){
		slaveAliasId = slaveAliasId.substring(0,1).toUpperCase()+slaveAliasId.substring(1,slaveAliasId.length-2);
		$($(".mtmCandidateForm").get(index)).find("#slaveAlias").textbox("setValue",slaveAliasId);
		$($(".mtmCandidateForm").get(index)).find("#slaveAliasId").textbox("setValue",slaveAliasId.substring(0,1).toLowerCase()+slaveAliasId.substring(1,slaveAliasId.length)+"Id");
	} else {
		$.messager.alert("错误", "slaveAliasId必须以Id结束！");
	}
}

function updateMtmCandidate(index){
	updateProjectAndAllDomains();
	$("#generateResults").html("");
	var masterName = $($(".mtmCandidateForm").get(index)).find("#masterName").combobox("getValue");
	var slaveName = $($(".mtmCandidateForm").get(index)).find("#slaveName").combobox("getValue");
	var slaveAlias = $($(".mtmCandidateForm").get(index)).find("#slaveAlias").textbox("getValue");
	var label = $($(".mtmCandidateForm").get(index)).find("#label").textbox("getValue");
	$.ajax({
        type: "post",
        url: "../facade/updateMtmCandidateByIndexFacade",
        data: { index: index,
        		masterName: masterName,
        		slaveName: slaveName,
        		slaveAlias: slaveAlias,
        		label:label},
        dataType: 'json',
        success: function(data, textStatus) {
           if (data.success == true){
        	   $.messager.alert("信息", "多对多候选更新成功，欢迎使用！");
        	   listServerData();
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function pureUpdateMtmCandidate(index){
	$("#generateResults").html("");
	var masterName = $($(".mtmCandidateForm").get(index)).find("#masterName").combobox("getValue");
	var slaveName = $($(".mtmCandidateForm").get(index)).find("#slaveName").combobox("getValue");
	var slaveAlias = $($(".mtmCandidateForm").get(index)).find("#slaveAlias").textbox("getValue");
	var label = $($(".mtmCandidateForm").get(index)).find("#label").textbox("getValue");
	$.ajax({
        type: "post",
        url: "../facade/updateMtmCandidateByIndexFacade",
        data: { index: index,
        		masterName: masterName,
        		slaveName: slaveName,
        		slaveAlias: slaveAlias,
        		label:label},
        dataType: 'json',
        async: false,
        success: function(data, textStatus) {
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function submitMtmCandidateData() {	
	var serial = $("#ffupdateMtmCandidateData").find("#serial").val();
	var index = $("#ffupdateMtmCandidateData").find("#index").val();
	var masterId = $("#ffupdateMtmCandidateData").find("#masterId").textbox("getValue");
	var slaveIds = $("#ffupdateMtmCandidateData").find("#slaveIds").textbox("getValue");
	pureUpdateMtmCandidate(serial);
	$.ajax({
        type: "post",
        url: "../facade/submitMtmCandidateWithSerailIndexFacade",
        data: { serial:serial, 
        		index: index,
        		masterId: masterId,
        		slaveIds: slaveIds
        		},
        dataType: 'json',
        success: function(data, textStatus) {
           if (data.success == true){
        	   $.messager.alert("信息", "多对多候选数据提交成功，欢迎使用！");
        	   listServerData();
        	   $('#wupdateMtmCandidateData').window('close');
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function deleteMtmCandidateData(serial){
	pureUpdateMtmCandidate(serial);
	var dg = $($("#domainsdiv").find("#mtmCandidateDg").get(serial));
	var rows = dg.datagrid('getSelections');
	var indexs = "";
	for (var i=0;i<rows.length;i++){
		indexs = indexs + dg.datagrid('getRowIndex',rows[i])+",";
	}
	if (indexs.includes(",")) indexs = indexs.substring(0,indexs.length - 1);
	updateProjectAndAllDomains();
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/deleteMtmCandidateDataBySerialByIndexFacade",
        data: { serial: serial,
        		indexs: indexs },
        dataType: 'json',
        success: function(data, textStatus) {
           if (data.success == true){
        	   $.messager.alert("信息", "多对多候选数据删除成功，欢迎使用！");
        	   listServerData();
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });
}

function deleteAllMtmCandidateData(serial){
	pureUpdateMtmCandidate(serial);
	$.ajax({
        type: "post",
        url: "../facade/deleteAllMtmCandidateDataBySerialFacade",
        data: { serial: serial },
        dataType: 'json',
        success: function(data, textStatus) {
           if (data.success == true){
        	   $.messager.alert("信息", "多对多候选全部数据删除成功，欢迎使用！");
        	   listServerData();
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });
}

function deleteMtmCandidate(index){
	updateProjectAndAllDomains();
	$("#generateResults").html("");
	$.ajax({
        type: "post",
        url: "../facade/deleteMtmCandidateByIndexFacade",
        data: { index: index },
        dataType: 'json',
        success: function(data, textStatus) {
           if (data.success == true){
        	   $.messager.alert("信息", "多对多候选删除成功，欢迎使用！");
        	   listServerData();
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function attachToDomain(serial){
	pureUpdateMtmCandidate(serial);
	$.ajax({
        type: "post",
        url: "../facade/attachMtmCandidateToDomainBySerialFacade",
        data: { serial: serial },
        dataType: 'json',
        success: function(data, textStatus) {
            if (data.success == true){
         	   $.messager.alert("信息", "多对多候选叠加成功，欢迎使用！");
         	   listServerData();
            } 
 		   if (data.success == false && !isBlank(data.compileErrors) && data.compileErrors.length > 0) {
         	   resultStr = "<span style='color:red;font-size:16pt''>";
         	   for (var i = 0; i < data.compileErrors.length;i++){
         		   resultStr += data.compileErrors[i];
         		   resultStr += "<br/>"
     	 		   }   
         	   resultStr += "</span>";
            }
     	   if (data.success == false && !isBlank(data.compileWarnings) && data.compileWarnings.length > 0){
         	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
         	   for (var i = 0; i < data.compileWarnings.length;i++){
         		   resultStr += data.compileWarnings[i];
         		   resultStr += "<br/>" 
         	   }
         	   resultStr += "</span>";
     	   }
     	   if (!!resultStr) $.messager.alert("错误", resultStr);
     	   resultStr = "";
         },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function showAddMtmCandidateData(serial){
	$("#ffupdateMtmCandidateData").find("#serial").val(serial);
	$("#ffupdateMtmCandidateData").find("#index").val("");
	$("#ffupdateMtmCandidateData").find("#masterId").textbox("setValue","");
	$("#ffupdateMtmCandidateData").find("#slaveIds").textbox("setValue","");
	$('#wupdateMtmCandidateData').window('open');
}

function showUpdateMtmCandidateData(serial){
	var rows = $($("#domainsdiv").find(".mtmCandidateDg").get(serial)).datagrid('getSelections');
	if (rows.length != 1) {
		$.messager.alert("警告", "请选择一条数据！");
		return;
	}
	var row = $($("#domainsdiv").find(".mtmCandidateDg").get(serial)).datagrid("getSelected");	
	var index = $($("#domainsdiv").find(".mtmCandidateDg").get(serial)).datagrid('getRowIndex',row);
	$("#ffupdateMtmCandidateData").find("#serial").val(serial);
	$("#ffupdateMtmCandidateData").find("#index").val(index);
	$("#ffupdateMtmCandidateData").find("#masterId").textbox("setValue",row.masterId);
	$("#ffupdateMtmCandidateData").find("#slaveIds").textbox("setValue",row.slaveIds);
	$('#wupdateMtmCandidateData').window('open');
}

function refleshWsetSepcial(serial){
	$("#domainfieldsform").find(".fieldrow").remove();
	var cols = getCols(serial);	
	$("#domainfieldsform").find("#domainiddeny").checkbox("check");
	$("#domainfieldsform").find("#domainnamedeny").checkbox("check");
	$("#domainfieldsform").find("#activefielddeny").checkbox("check");
	$("#domainfieldsform").find("#domainid").textbox("setValue","");
	$("#domainfieldsform").find("#domainidlabel").textbox("setValue","");
	$("#domainfieldsform").find("#domainidfixedname").textbox("setValue","");
	$("#domainfieldsform").find("#domainname").textbox("setValue","");
	$("#domainfieldsform").find("#domainnamelabel").textbox("setValue","");
	$("#domainfieldsform").find("#domainnamefixedname").textbox("setValue","");
	$("#domainfieldsform").find("#activefield").textbox("setValue","");	
	$("#domainfieldsform").find("#activefieldlabel").textbox("setValue","");
	$("#domainfieldsform").find("#activefieldfixedname").textbox("setValue","");
	
	$("#domainfieldsform").find("#domainidtype").textbox("setValue","Long");
	$("#domainfieldsform").find("#domainnametype").textbox("setValue","String");
	$("#domainfieldsform").find("#activefieldtype").textbox("setValue","Boolean");	

	var myindex = 0;
	for (var i =0;i<cols.length;i++){
		 if (cols[i].title=="domainid"){
			$("#domainfieldsform").find("#domainid").textbox("setValue",cols[i].field);
			$("#domainfieldsform").find("#domainidtype").textbox("setValue",cols[i].fieldtype);
			$("#domainfieldsform").find("#domainidlabel").textbox("setValue",cols[i].label);
			$("#domainfieldsform").find("#domainidfixedname").textbox("setValue",cols[i].fixedName);
			$("#domainfieldsform").find("#domainiddeny").checkbox("uncheck");
		}else if (cols[i].title=="domainname"){
			$("#domainfieldsform").find("#domainname").textbox("setValue",cols[i].field);
			$("#domainfieldsform").find("#domainnametype").textbox("setValue",cols[i].fieldtype);
			$("#domainfieldsform").find("#domainnamelabel").textbox("setValue",cols[i].label);
			$("#domainfieldsform").find("#domainnamefixedname").textbox("setValue",cols[i].fixedName);
			$("#domainfieldsform").find("#domainnamedeny").checkbox("uncheck");
		}else if (cols[i].title=="activefield"){
			$("#domainfieldsform").find("#activefield").textbox("setValue",cols[i].field);
			$("#domainfieldsform").find("#activefieldtype").textbox("setValue",cols[i].fieldtype);
			$("#domainfieldsform").find("#activefieldlabel").textbox("setValue",cols[i].label);
			$("#domainfieldsform").find("#activefieldfixedname").textbox("setValue",cols[i].fixedName);
			$("#domainfieldsform").find("#activefielddeny").checkbox("uncheck");
		}else{
			if (!isBlank(cols[i].title)&&cols[i].title=="元字段类型") continue;
			addFieldRow();
			$.parser.parse($("#domainfieldsform").find(".fieldrow:last"));
			$($("#domainfieldsform").find(".fieldcatlog").get(myindex)).combobox("setValue",cols[i].title);
			$($("#domainfieldsform").find(".field").get(myindex)).textbox("setValue",cols[i].field);
			$($("#domainfieldsform").find(".fieldoriginalcatlog").get(myindex)).val(cols[i].title);
			$($("#domainfieldsform").find(".fieldoriginalname").get(myindex)).val(cols[i].field);
			$($("#domainfieldsform").find(".fieldtype").get(myindex)).combobox("setValue",cols[i].fieldtype);
			$($("#domainfieldsform").find(".fieldlength").get(myindex)).textbox("setValue",cols[i].fieldlength);
			$($("#domainfieldsform").find(".fieldlabel").get(myindex)).textbox("setValue",cols[i].label);
			$($("#domainfieldsform").find(".fieldfixedname").get(myindex)).textbox("setValue",cols[i].fixedName);
			myindex++;
		}
	}
	//$.parser.parse($("#domainfieldsform"));
	$('#domainfieldsform').find("#serial").val(serial);	
}

function mtmCandidateToDomain(serial){
	$.ajax({
        type: "post",
        url: "../facade/switchMtmCandidateToDomainWithSerialFacade",
        data: {serial:serial,
       	},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
				$.messager.alert("信息", "多对多候选转换为域对象成功，欢迎使用！");			
				listServerData();
           }			
           if (!isBlank(data.compileErrors) && data.compileErrors.length > 0) {
        	   resultStr = "<span style='color:red;font-size:16pt''>";
        	   for (var i = 0; i < data.compileErrors.length;i++){
        		   resultStr += data.compileErrors[i];
        		   resultStr += "<br/>"
    	 		   }   
        	   resultStr += "</span>";
           }
    	   if (!isBlank(data.compileWarnings) && data.compileWarnings.length > 0){
        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
        	   for (var i = 0; i < data.compileWarnings.length;i++){
        		   resultStr += data.compileWarnings[i];
        		   resultStr += "<br/>" 
        	   }
        	   resultStr += "</span>";
    	   }
    	   if (!!resultStr) $.messager.alert("错误", resultStr);
    	   resultStr = "";
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}


function switchDomainToMtmCandidate(serial){
	$.ajax({
        type: "post",
        url: "../facade/switchDomainToMtmCandidateWithSerialFacade",
        data: {serial:serial,
       	},
        dataType: 'json',
        success: function(data, textStatus) {
			debugger;
           if (data.success == true){
				$.messager.alert("信息", "多对多候选转换为域对象成功，欢迎使用！");			
				listServerData();
           }
			if (!isBlank(data.compileErrors) && data.compileErrors.length > 0) {
	        	   resultStr = "<span style='color:red;font-size:16pt''>";
	        	   for (var i = 0; i < data.compileErrors.length;i++){
	        		   resultStr += data.compileErrors[i];
	        		   resultStr += "<br/>"
        	 		   }   
	        	   resultStr += "</span>";
	           }
        	   if (!isBlank(data.compileWarnings) && data.compileWarnings.length > 0){
	        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
	        	   for (var i = 0; i < data.compileWarnings.length;i++){
	        		   resultStr += data.compileWarnings[i];
	        		   resultStr += "<br/>" 
	        	   }
	        	   resultStr += "</span>";
        	   }
        	   if (!!resultStr) $.messager.alert("错误", resultStr);
        	   resultStr = "";
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function toggleAutoConfig(){
	if ($("#autoConfig").get(0).checked==true){
		$("#frontUseProjectName").attr("disabled","disabled");
		$("#frontUseControllerPrefix").attr("disabled","disabled");
	}else{
		$("#frontUseProjectName").removeAttr("disabled");
		$("#frontUseControllerPrefix").removeAttr("disabled");
	}
}
</script> 
</html>
